Tag Archives: Push

GitBlit Pre Hook to Prevent Pushing Certain Commit

Git in practice.

There are many different Git workflows and it is very likely that the one you are using relies heavily on Git’s outstanding branch management.

If you have many branches, some of which may be release branches, you surely don’t want anyone to merge a feature branch branched off of develop into it (which already probably is dozens of commits ahead).

This is extremely important in teams formed by many developers – if one of them makes the mistake, and the others start branching off of the release branch, all of them will have the “corrupted” version of the branch, and then it takes a lot of effort to undo all of the damage.

Git doesn’t provide a way to deal with this problem out of the box – a pre hook is required, or some third-party software.

If you are using GitBlit, however, writing a pre hook which guards a branch from being flooded with commits from a branch which should never be merged into it, is quite easy.

Below simple groovy script achieves just that: Continue reading