有没有办法使用 git post-commit hook 获取提交的受影响文件?
我在 perforce 存储库中使用 git。我希望能够准确地知道哪些文件受到 git 提交的影响,这样我就可以使用提交后挂钩并打开这些文件在 perforce 中进行编辑,以便 perforce 服务器知道这些更改。
有没有办法可以在提交后挂钩中获取受提交影响的文件的列表?
I'm using git within a perforce repository. I want to be able to know exactly 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
获取当前分支头的受影响路径(相对于
$GIT_DIR
)Get the affected paths (relative to
$GIT_DIR
) of the current branch's head with要获取原始数据:
git 差异树 HEAD
To get the raw data:
git diff-tree HEAD
是
git log --name-only
您要找的吗?git log --name-status
还显示 M 表示修改、A 表示添加(我推测)等操作。最后,选项
--pretty=oneline
可能是方便更容易解析。显然您可能已经弄清楚了这一点,但我添加了这一点以供将来参考。
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.