开发者

git hooks push and local commits

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 pu开发者_Go百科sh back to the main corporate branch.

Thoughts? Is this the best practice?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜