哪些git钩子适用于'git rebase --continue'? [英] What git hooks apply to 'git rebase --continue'?

查看:149
本文介绍了哪些git钩子适用于'git rebase --continue'?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我的组织构建一组git hook脚本,而我想使用的(对于我自己的多个项目而言)将是检查git rebase --continue我没有任何脚本与我的代码(<<<<<=====>>>>>)中剩余的标记发生冲突.

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 >>>>>).

我已经有这样的脚本用于预提交,但是什么脚本适用于rebase --continue?

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

推荐答案

联机帮助页 githooks 列出了可用的git钩子. 没有git rebase --continue的钩子(列表很详尽).

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

有一个钩子"post-rewrite",它由重写提交的命令调用",例如git rebase.但是,它仅在命令完成后(即重新设置完成后)运行.

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).

它将为您提供由重写创建的新提交的列表,因此您可以检查这些提交是否引入了任何冲突标记并进行投诉,但是此时放弃中止基准为时已晚.当然,您仍然可以使用reflog还原基准.

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.

总而言之,为git rebase编写一些包装程序或使用单独的检查工具手动调用可能更容易.无论如何,您应该(IMHO)在调用git rebase --continue之前始终查看所做的更改.如果您坚持这样做,就不会意外签入冲突标记.

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.

这篇关于哪些git钩子适用于'git rebase --continue'?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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