How to replace local git hooks with updated versions with git init?

I have exactly the same question as this user here:

git init template, replacing modified hooks

I have a new template file in my global git hooks. However, the original template file was already loaded, so git init does not overwrite. I read the same here, this appears to be the correct git behaviour:

From http://www.cs.potsdam.edu/cgi-bin/man/man2html?1+git-init:

Running git init in an existing repository is safe. It will not overwrite things that are already there. The primary reason for rerunning git init is to pick up newly added templates.

So what is a good way to force reloading new git template hooks? I have many hooks in many git repos, on several computers and used by a variety of users. The most practical way is to have the users run a specific command, rather than telling them to remove the hook first and then run the git init command. Is there a way of doing this?


The most practical way is to have the users run a specific command, rather than telling them to remove the hook first and then run the git init command

In that case, a possible way would be to distribute to those users a script which does just that (you could version that script in each of your repo).
Instead of doing the git init directly, they would call that script which would:

  • remove the hooks
  • call the git init
  • 链接地址: http://www.djcxy.com/p/10834.html

    上一篇: 找到矩阵中具有某些属性的所有矩形区域

    下一篇: 如何用git init替换更新后的本地git钩子?