How to list all the files in a commit?

后端 未结 30 2361
一个人的身影
一个人的身影 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:26

    I personally use the combination of --stat and --oneline with the show command:

    git show --stat --oneline HEAD
    git show --stat --oneline b24f5fb
    git show --stat --oneline HEAD^^..HEAD
    

    If you do not like/want the addition/removal stats, you can replace --stat with --name-only

    git show --name-only --oneline HEAD
    git show --name-only --oneline b24f5fb
    git show --name-only --oneline HEAD^^..HEAD
    
    0 讨论(0)
  • 2020-11-22 02:26

    Display the log.

    COMMIT can be blank ("") or the sha-1 or the sha-1 shortened.

    git log COMMIT -1 --name-only
    

    This will list just the files, very useful for further processing.

    git log COMMIT -1 --name-only --pretty=format:"" | grep "[^\s]"
    
    0 讨论(0)
  • 2020-11-22 02:28

    OK, there are couple of ways to show all files in a particular commit...

    To reduce the info and show only names of the files which committed, you simply can add --name-only or --name-status flag..., these flags just show you the file names which are different from previous commits as you want...

    So you can do git diff followed by --name-only, with two commit hashes after <sha0> <sha1>, something like below:

    git diff --name-only 5f12f15 kag9f02 
    

    I also create the below image to show all steps to go through in these situation:

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

    You can also do

    git log --name-only
    

    and you can browse through various commits, commit messages and the changed files.

    Type q to get your prompt back.

    0 讨论(0)
  • 2020-11-22 02:31
    $ git log 88ee8^..88ee8 --name-only --pretty="format:"
    
    0 讨论(0)
  • 2020-11-22 02:32

    I use this to get list of modified files between two changesets:

    git diff --name-status <SHA1> <SHA2> | cut -f2
    
    0 讨论(0)
提交回复
热议问题