How to list all the files in a commit?

后端 未结 30 2295
一个人的身影
一个人的身影 2020-11-22 01:50

I am looking for a simple git command that provides a nicely formatted list of all files that were part of the commit given by a hash (SHA1), with no extraneous

相关标签:
30条回答
  • 2020-11-22 02:16

    Only the file list (not even commit message):

    git show --name-only --pretty=format:
    

    E.g. open all changed files in your editor:

    git show --name-only --pretty=format: | xargs "$EDITOR"
    
    0 讨论(0)
  • 2020-11-22 02:19

    Recently I needed to list all changed files between two commits. So I used this (also *nix specific) command

    git show --pretty="format:" --name-only START_COMMIT..END_COMMIT | sort | uniq
    

    Update: Or as Ethan points out below

    git diff --name-only START_COMMIT..END_COMMIT
    

    Using --name-status will also include the change (added, modified, deleted etc) next to each file

    git diff --name-status START_COMMIT..END_COMMIT
    
    0 讨论(0)
  • 2020-11-22 02:19

    I use changed alias a quite often. To set it up:

    git config --global alias.changed 'show --pretty="format:" --name-only'
    

    then:

    git changed (lists files modified in last commit)   
    git changed bAda55 (lists files modified in this commit)
    git changed bAda55..ff0021 (lists files modified between those commits)
    

    Similar commands that may be useful:

    git log --name-status --oneline (very similar, but shows what actually happened M/C/D)
    git show --name-only
    
    0 讨论(0)
  • 2020-11-22 02:19

    List the files that changed in a commit:

    git diff --name-only SHA1^ SHA1
    

    This doesn't show log messages, extra newlines, or any other clutter. This works for any commit, not just the current one. Not sure why it hasn't quite been mentioned yet, so I'm adding it.

    0 讨论(0)
  • 2020-11-22 02:19

    This should work:

    git status
    

    This will show what is not staged and what is staged.

    0 讨论(0)
  • 2020-11-22 02:21

    If you want to get list of changed files:

    git diff-tree --no-commit-id --name-only -r <commit-ish>
    

    If you want to get list of all files in a commit, you can use

    git ls-tree --name-only -r <commit-ish>
    
    0 讨论(0)
提交回复
热议问题