How to show changed file name only with 'git log' [duplicate]

Is it able to show changed file name only with git log?


Solution 1:

I use

git log --name-only 

or

git log --name-only --oneline

for short.

Solution 2:

I guess you could use the --name-only flag. Something like:

git log 73167b96 --pretty="format:" --name-only

I personally use git show for viewing files changed in a commit:

git show --pretty="format:" --name-only 73167b96

(73167b96 could be any commit/tag name)

Solution 3:

I stumbled in here looking for a similar answer without the "git log" restriction. The answers here didn't give me what I needed but this did so I'll add it in case others find it useful:

git diff --name-only

You can also couple this with standard commit pointers to see what has changed since a particular commit:

git diff --name-only HEAD~3
git diff --name-only develop
git diff --name-only 5890e37..ebbf4c0

This succinctly provides file names only which is great for scripting. For example:

git diff --name-only develop | while read changed_file; do echo "This changed from the develop version: $changed_file"; done

#OR

git diff --name-only develop | xargs tar cvf changes.tar

Solution 4:

This gives almost what you need:

git log --stat --oneline

The commit ID and a short one line still remains, followed by a list of changed files by that commit.

Solution 5:

Now I use the following to get the list of changed files my current branch has, comparing it to master (the compare-to branch is easily changed):

git log --oneline --pretty="format:" --name-only master.. | awk 'NF' | sort -u

Before, I used to rely on this:

git log --name-status <branch>..<branch> | grep -E '^[A-Z]\b' | sort -k 2,2 -u

which outputs a list of files only and their state (added, modified, deleted):

A   foo/bar/xyz/foo.txt
M   foo/bor/bar.txt
...

The -k2,2 option for sort, makes it sort by file path instead of the type of change (A, M, D,).