We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
这里是使用 Python 进行挂钩的示例。一般来说,钩子与语言无关。您可以使用该脚本执行某些工作或以 0/其他返回代码退出来更改 git 进程的流程。
Here is an example of using Python for a hook. In general the hooks are language agnostic. You use the script to do some work or to exit with a 0/other return code to alter the flow of a git process.
git自带的例子是用shell脚本写的;每个存储库的 .git/hooks 中都有一些基本的,而更高级的则安装到 /usr/share/doc/git-core/contrib/hooks 中。
通过
$ man githooks
还可以获得有关各种挂钩的更多信息。The examples that come with git are written in shell script; there are some basic ones in
.git/hooks
of each repo and more advanced ones installed to/usr/share/doc/git-core/contrib/hooks
.There's also more info on the various hooks available via
$ man githooks
.我发现在python上写git hook很容易。这是 python 上的 post-receive hook 的一个例子。提供的示例在不同的文件夹中部署主分支和开发分支(主分支中的更改将被推送到生产网站,开发分支中的更改将被推送到质量保证站点)
I found out that it's easy to write git hook on python. It's an example of post-receive hook on python. Provided example deploys master and develop branches in different folders (changes in master will be pushed to production website and changes in develop branch will be pushed to qa site)