Rename a file foo.txt
to bar.txt
, then git add. I would like to get all changed file paths. Since it's a rename we are technically changing two file paths:
foo.txt
bar.txt
What I've tried
git diff --name-only
-- only gives bar.txt
git diff --name-only HEAD...
gives nothing because the ...
syntax just puts head at the end.
git diff --name-only ...HEAD
gives nothing.
Here's how to do it if I commit my changes (but that's not the question here)
git diff --name-only HEAD~1 HEAD
-- will spit out bar.txt
but requires two commit hashes. My changes are not committed, so I don't have a hash.
git diff --name-only HEAD HEAD~1
-- will spit out foo.txt
but requires two commit hashes. My changes are not committed, so I don't have a hash.
CodePudding user response:
Name-only just shows you the current (or last, for deleted) names of affected files. If you want more details on what happened to them,
git diff --name-status @
Since you git added
the rename, it's already in your index, the remaining difference is from your checked out commit @
aka HEAD
.
You could also git diff --name-status --cached @
to show any changes in what you've added, ignoring the work tree.