tags:

views:

81

answers:

1

I have recently been writing git hooks for my project team. I would like to know if developers are making various commits locally, without following the standard commit message pattern. then they push those commits. Will there push fail because there commits weren't following the pattern?

The desired result would be they are able to commit locally as they wish, then are forced to follow a structure way when they push back to the main corporate branch.

Thoughts? Is this the best practice?

+2  A: 

The trick is: git hooks are not published (pushed/pulled)

So if your project members push to a bare repo where a server-side hook (pre-receive or update) check for the commit message pattern (which I am not sure it can be done), that push will fail.
But the commit lives on the developer local repo and he/she still has to fix it (git commit --amend if no other commits have already been done).

It would be better to:

  • make a template Git repo with the right hooks
  • make sure the developers initialize their repo with the --template option referencing the right common template.
    See template directory section of git init.

That way, they will fail quicker than on the server side (where n incorrect commits can be pushed, and will fail)

In other work, here a client-side hook would be more appropriate.

VonC