How would I write a pre-merge hook in Git?

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

Leave a Comment

404 Not Found

Not Found

The requested URL was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.