3

We have a git workflow which is mostly based on rebasing local topic branches, as to achieve as linear a commit tree as possible. However sometimes it is necessary to merge and we do allow that.

How can I set up my git server to warn the user, when they try to push a merge commit to the server? I would like to just warn the user and ask them to confirm that this is what they really want to do.

Bjarke Freund-Hansen
  • 26,102
  • 24
  • 88
  • 134

1 Answers1

3

I don't think you can do this interactively in the way that your question suggests if you are using standard versions of git. One possible alternative, however, is to have a pre-receive hook on the server that will refuse any merge commits that don't contain a particular string, say Merge Reviewed. The error output by the pre-receive hook on receiving a push that would introduce such a merge commit would also suggest using history rewriting (git commit --amend or git rebase) to add that string or rebase into linear history before pushing.

Mark Longair
  • 415,589
  • 70
  • 403
  • 320
  • Reading a bit up on git hooks it seems the `update` hook should actually be perfect, as it allows interactive communication with the client. (stdout is redirected to the remote git client doing the push, and vice verse for stdin.) However I was really hoping someone has made a similar script in the past I can use or modify to my needs. – Bjarke Freund-Hansen Nov 08 '11 at 07:36