在推送过程中,如何在GIT中更改文件 [英] How to discover a file is changed in GIT during a push

查看:142
本文介绍了在推送过程中,如何在GIT中更改文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我将某些东西推到我的GIT存储库时,post-receive钩子被触发并执行一些脚本。是否有可能在执行这些脚本之前执行某些操作(并且只在特定文件相对于上一次推送(例如.sql文件)发生更改时)?

感谢



随机化

解决方案

第一步或在预接收或更新钩子中,您可以使用

  git diff-tree --name-status -rz 

并传递新的和旧的引用传入钩子(stdin或参数)并获取文件,检查修改后的M - 状态在输出中,并做你需要的。



另见这里的替代方法: http://progit.org/book/ch7-4.html


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中更改文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆