Reputation: 451
How do I execute the following command getting filenames without paths?
So, literally, what the command says, "name-only" - not the file paths, just the file names.
git diff --name-only <commit> <commit>
Upvotes: 3
Views: 3170
Reputation: 15189
AFAIK this is not provided by git since this is a pretty unusual requirement. For example my first try in my repository yielded about a dozen lines, each saying pom.xml
because I just created a new version.
You can use a small script though. basename
is your friend here.
I like xargs
so I'd do it like this
git diff --name-only <commit> <commit> | xargs -n1 basename
This will fail if git diff
provides no output.
Or for a loopy version
for s in `git diff --name-only <commit> <commit>` ; do basename $s ; done
Upvotes: 3