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, t
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:
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
wechdir()
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
ingit-init.txt
mentions nothing about this behavior.
Change it to be relative to$CWD
, which is much more intuitive.