How to list all the files in a commit?

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

    I use this to get list of changed files in merge commit

    λ git log -m -1 --name-only --pretty="format:"
    configs/anotherconfig.xml
    configs/configsInRepo.xml
    

    or

    λ git log -m -1 --name-status --pretty="format:"
    A       configs/anotherconfig.xml
    M       configs/configsInRepo.xml
    
    0 讨论(0)
  • 2020-11-22 02:33

    Simplest form:

    git show --stat (hash)

    That's easier to remember and it will give you all the information you need.

    If you really want only the names of the files you could add the --name-only option.

    git show --stat --name-only (hash)

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

    Found a perfect answer to this:

    git show --name-status --oneline <commit-hash>
    

    So that I can know

    which files were just modified M
    
    Which files were newly added , A
    
    Which files were deleted , D
    
    0 讨论(0)
  • 2020-11-22 02:36

    I thought I would share a summary of my alias.. also I find using 'zsh' great with git it chroma keys everything nicely and tells you want branch are in all of the time by changing the command prompt.

    For those covering from SVN you will find this useful: (this is a combination of ideas from different threads, I only take credit of knowing how to use copy/paste)

    .gitconfig:
            ls = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)%an%Creset' --abbrev-commit --date=relative --name-status
    
    >>git ls
    * 99f21a6 - (HEAD -> swift) New Files from xcode 7 (11 hours ago) Jim Zucker| 
    | A     icds.xcodeproj/project.pbxproj
    | A     icds.xcodeproj/project.xcworkspace/contents.xcworkspacedata
    | A     icds/AppDelegate.m
    | A     icds/Assets.xcassets/AppIcon.appiconset/Contents.json
    
    * e0a1bb6 - Move everything to old (11 hours ago) Jim Zucker| 
    | D     Classes/AppInfoViewControler.h
    | D     Classes/AppInfoViewControler.m
    | D     Classes/CurveInstrument.h
    
    
    .gitconfig: 
           lt = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)%an%Creset' --abbrev-commit --date=relative
    
    >>git lt
    * 99f21a6 - (HEAD -> swift) New Files from xcode 7 (11 hours ago) Jim Zucker
    * e0a1bb6 - Move everything to old (11 hours ago) Jim Zucker
    * 778bda6 - Cleanup for new project (11 hours ago) Jim Zucker
    * 7373b5e - clean up files from old version (11 hours ago) Jim Zucker
    * 14a8d53 - (tag: 1.x, origin/swift, origin/master, master) Initial Commit (16 hours ago) Jim Zucker
    
    
    .gitconfig
    lt = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)%an%Creset' --abbrev-commit --date=relative
    
    >> git lt
    
    commit 99f21a61de832bad7b2bdb74066a08cac3d0bf3c
    Author: Jim Zucker <jim@stratengllc.com>
    Date:   Tue Dec 1 22:23:10 2015 -0800
    
        New Files from xcode 7
    
    A       icds.xcodeproj/project.pbxproj
    A       icds.xcodeproj/project.xcworkspace/contents.xcworkspacedata
    
    
    commit e0a1bb6b59ed6a4f9147e894d7f7fe00283fce8d
    Author: Jim Zucker <jim@stratengllc.com>
    Date:   Tue Dec 1 22:17:00 2015 -0800
    
        Move everything to old
    
    D       Classes/AppInfoViewControler.h
    D       Classes/AppInfoViewControler.m
    D       Classes/CurveInstrument.h
    D       Classes/CurveInstrument.m
    
    0 讨论(0)
  • 2020-11-22 02:37

    Use

    git log --name-status
    

    This will show you the commit id, message, the files changed and whether it was modified, created, added or deleted. Somewhat of a all-in-one command.

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

    Use simple one line command, if you just want the list of files changed in the last commit:

    git diff HEAD~1 --name-only
    
    0 讨论(0)
提交回复
热议问题