I'm using git within a perforce repository. I want to be able to know exactl开发者_开发问答y what files were affected by a git commit so I can turn around with a post-commit hook and open those files for edit in perforce, so the perforce server knows about the changes.
Is there a way I can get a list, within the post-commit hook, of exactly what files were affected by the commit?Get the affected paths (relative to $GIT_DIR
) of the current branch's head with
git show --pretty=oneline --name-only HEAD | sed 1d
To get the raw data:
git diff-tree HEAD
is git log --name-only
what you're looking for? git log --name-status
also shows the action like M for modified, A for added (i presume) etc.
Lastly, the option --pretty=oneline
might be handy for easier parsing.
Obviously you've probably figured this out already but I added this for future reference.
精彩评论