What git hooks apply to 'git rebase --continue'?

廉价感情. 提交于 2019-12-05 16:31:31

问题


I'm trying to build a set of git hook scripts for my organization, and one I would like to use (for multiple project just for myself) would be to check upon a git rebase --continue that I don't have any conflicts markers leftover in my code (<<<<<, =====, or >>>>>).

I already have such a script for my pre-commit, but what script applies on a rebase --continue ?


回答1:


The manpage githooks has a list of the available git hooks. There is no hook for git rebase --continue (the list is exhaustive).

There is a hook "post-rewrite", which "is invoked by commands that rewrite commits", such as git rebase. However, it only runs once the command is done (i.e. when the rebase is finished).

It will give you the list of new commits created by the rewrite, so you could check if the commits introduce any conflicts markers and complain, but at that point it is too late to abort the rebase. You can still revert the rebase using the reflog, of course.

All in all, it is probably easier to write some wrapper for git rebase, or a separate checking tool to invoke manually. At any rate, you should (IMHO) always review the changes you made before invoking git rebase --continue. If you stick to doing that, you will not accidentally have conflict markers checked in.



来源:https://stackoverflow.com/questions/22017029/what-git-hooks-apply-to-git-rebase-continue

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!