how do i identify files/directories that were added or removed in a git commit?

前端 未结 2 853
傲寒
傲寒 2021-02-18 18:43

I need to write a script that incrementally keeps track of files and directories added and removed from a git repo.

I have tried to use:

git log -n1 --         


        
相关标签:
2条回答
  • 2021-02-18 19:16

    The option you're looking for is --name-status. Like --name-only it's actually a git-diff option; git-log accepts those to determine how it'll display patches.

    git log -n 1 --pretty=oneline --name-status
    

    Or equivalently (minus the log header):

    git diff --name-status HEAD^ HEAD
    

    As isbadawi points out, you can also use git-whatchanged. This is pretty much git-log with a specific diff output:

    git whatchanged -n 1
    

    You might like the --name-status version better, though, since it doesn't show all the blob hashes, just the human-readable statuses.

    0 讨论(0)
  • 2021-02-18 19:26

    git whatchanged

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