我如何在Git中编写预合并钩子? [英] How would I write a pre-merge hook in Git?
问题描述
pre-commit
钩子,但我不太确定。您可以尝试使用 prepare-commit-msg
钩子。如果提交是合并或 .git / MERGE_MSG
文件存在,则第二个参数将为 merge
。非零退出状态将中止提交。
我认为这不适用于快进合并,因为不会有提交消息。
更多关于钩子的信息: https://www.kernel.org/pub/software/scm/git/docs/githooks.html#_prepare_commit_msg
The question says it all. Is there a way to perform an action before a merge? I'm guessing there's a way to make use of a pre-commit
hook, but I'm not quite sure.
You can try using the prepare-commit-msg
hook. The second argument will be merge
"if the commit is a merge or a .git/MERGE_MSG
file exists". A non-zero exit status will abort the commit.
I don't think this will work with a fast-forward merge, since there won't be a commit message.
More info on hooks: https://www.kernel.org/pub/software/scm/git/docs/githooks.html#_prepare_commit_msg
这篇关于我如何在Git中编写预合并钩子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!