Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

githooks

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 ?

like image 672
Yeraze Avatar asked Feb 25 '14 14:02

Yeraze


People also ask

What is git rebase continue?

When you're finished making all your changes, you can run git rebase --continue . As before, Git is showing the commit message for you to edit. You can change the text ( "i cant' typ goods" ), save the file, and close the editor. Git will finish the rebase and return you to the terminal.

What are git hooks used for?

Git hooks are scripts that run automatically every time a particular event occurs in a Git repository. They let you customize Git's internal behavior and trigger customizable actions at key points in the development life cycle.

What is pre-commit hook in git?

The pre-commit hook is run first, before you even type in a commit message. It's used to inspect the snapshot that's about to be committed, to see if you've forgotten something, to make sure tests run, or to examine whatever you need to inspect in the code.

How do you attach a Precommit hook?

Open a terminal window by using option + T in GitKraken Client. Once the terminal windows is open, change directory to . git/hooks . Then use the command chmod +x pre-commit to make the pre-commit file executable.


1 Answers

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.

like image 82
sleske Avatar answered Sep 21 '22 16:09

sleske