问题描述
当我将某些东西推到我的GIT存储库时,post-receive钩子被触发并执行一些脚本。是否有可能在执行这些脚本之前执行某些操作(并且只在特定文件相对于上一次推送(例如.sql文件)发生更改时)?
感谢
随机化
第一步或在预接收或更新钩子中,您可以使用
git diff-tree --name-status -rz
并传递新的和旧的引用传入钩子(stdin或参数)并获取文件,检查修改后的M - 状态在输出中,并做你需要的。
另见这里的替代方法:
when I push something to my GIT repository, the post-receive hook is triggered and executes some scripts. Is it possible doing something before the execution these scripts if (and only if) a specific file is changed respect to the previous push (for example .sql file)?
Thanks
Randomize
In the same post-receive hook as a first step or in a pre-receive or update hook, you can use
git diff-tree --name-status -rz
and pass in the new and old ref that are passed in to the hook ( either stdin or arguments) and get the files, check for modified - M - status in the output and do what you need.
Also see here for alternate ways: http://progit.org/book/ch7-4.html
这篇关于在推送过程中,如何在GIT中更改文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!