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

余生长醉 提交于 2019-12-01 03:49:24

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 --template=

But beware of the path you are using with the --temaplate option.
A relative pathname given to "git init --template=<path> <repo>" ought to be relative to the directory "git init" gets invoked in, but it instead was made relative to the repository, which has been corrected with Git 2.22.1 (Q2 2019).

See commit e1df7fe (10 May 2019) by Nguyễn Thái Ngọc Duy (pclouds).
(Merged by Junio C Hamano -- gitster -- in commit 35d7715, 25 Jul 2019)

init: make --template path relative to $CWD

During git-init we chdir() to the target directory, but --template is not adjusted.
So it's relative to the target directory instead of current directory.

It would be ok if it's documented, but --template in git-init.txt mentions nothing about this behavior.
Change it to be relative to $CWD, which is much more intuitive.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!