JacobIRR JacobIRR -4 years ago 58
Git Question

Bash / xargs trick to open all files that changed in git HEAD

I open files from Terminal in Sublime Text and do so using a shortcut like this:

$ subl <filename>

...what I'm hoping to do is open all files that changed in my last git commit.

I can see all files that changed like so:

$ git show --name-only HEAD
commit b2c891f64daab0dc67df5cde9608602c7cde2f7b
Author: Jacob
Date: Fri Jun 9 16:52:05 2017 -0700

start doing some cool stuff; ref 12345


... but this command shows more info besides the filenames themselves.

I want to do something like:

$ git show --name-only HEAD | <get the lines out that aren't filenames> | xargs -i subl {}

Does this require
? Or a different
flag that I can't find?

Answer Source

Use diff: git diff --name-only HEAD~

subl `git diff --name-only HEAD~`

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download