How to list all the files in a commit?

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

    Using standard git diff command (also good for scripting):

    git diff --name-only <sha>^ <sha>
    

    If you want also the status of the changed files:

    git diff --name-status <sha>^ <sha>
    

    This works well with merge commits.

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

    A combination of "git show --stat" (thanks Ryan) and a couple of sed commands should trim the data down for you:

    git show --stat <SHA1> | sed -n "/ [\w]\*|/p" | sed "s/|.\*$//"
    

    That will produce just the list of modified files.

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

    try this command for name and changes number of line

    git show --stat <commit-hash>
    

    only show file names

    git show --stat --name-only  <commit-hash>
    

    for get last commit hash then try this command

    git log -1
    

    last commit with show files name and file status modify,create or delete

     git log -1 --oneline --name-status <commit-hash>
    

    or for all

    git log
    

    for more advanced git log information read this article

    https://devhints.io/git-log-format

    https://devhints.io/git-log

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

    I'll just assume that gitk is not desired for this. In that case, try git show --name-only <sha>.

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

    I like to use

    git show --stat <SHA1>^..<SHA2>
    
    0 讨论(0)
  • 2020-11-22 02:43
    git show HEAD@{0}
    

    works fine for me

    0 讨论(0)
提交回复
热议问题