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>
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
basename? You should probably add any such constraints to your question.git diff. This version also has no particular dependencies on bash.
for i in `git diff --name-only <commit> <commit>` ; do basename $i ; doneREADME.txtfiles in different subdirectories? Why do you want to ignore the paths?README.txtfile once. From my comment below, "My manager is content with the file paths included, I assumed he didn't want them, so I panicked and made this question"