In a git post-commit hook how do I get a list of the files that were changed?

后端 未结 2 1630
情深已故
情深已故 2021-01-02 05:02

Trying to figure out how long time was spent in a commit in a Git post-commit hook.

I\'ve got a post-commit git hook that submits information over an API about the c

2条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-02 05:43

    When writing scripts around git, you should try to stick to the plumbing commands — their format is less likely to change and easier to parse. Here is a command which outputs the names of the paths which changed in a commit:

    git diff-tree -r --name-only --no-commit-id 
    

    That aside, you may wish to examine the index, as it contains timestamps about when the files were staged, which might give you an extra edge; however, I don’t believe there is a way to access this information.

提交回复
热议问题