How to show changed file name only with git log?

This question already has an answer here:

  • How to have git log show filenames like svn log -v

    7 answers

  • What is a good workflow for git-annex?
  • Would you migrate from cvs to svn or directly to git or hg?
  • Force Adding Submodule Contents in Git
  • Find size of git repo
  • Git Merge Conflict with Yaml files
  • Why can't I commit my code to GitHub?
  • How to make a copy of a remote git branch (without merging with my existing branch)?
  • git clone give an empty repository but the repository isn't empty
  • git merging branches in a bare repository
  • How to make git output show red or orange color when it contains the word “error”, “warning”, or “Aborting”?
  • Correctly configure Git with Jenkins under Windows 7
  • How to change a fresh git repository into a branch from another repo?
  • 6 Solutions collect form web for “How to show changed file name only with git log?”

    Thanks for your answers, @mvp, @xero, I get what I want base on both of your answers.

    git log --name-only 


    git log --name-only --oneline

    for short.

    i guess your 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)

    This gives almost what you need:

    git log --stat --oneline

    Commit id + short one line still remains, followed by list of changed files by that commit.

    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
    git diff --name-only develop | xargs tar cvf changes.tar

    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,).

    If you need just file names like:


    (which I use as a source for tar command) you will also need to filter out commit messages.

    In order to do this I use following command:

    git log --name-only --oneline | grep -v '.{7} '

    Grep command excludes (-v param) every line which starts with seven symbols (which is the length of my git hash for git log command) followed by space. So it filters out every git hash message line and leave only lines with file names.

    One useful improvement is to append uniq to remove duplicate lines so it will looks as follow:

    git log --name-only --oneline | grep -v '.{7} ' | uniq

    Git Baby is a git and github fan, let's start git clone.