我尝试使用git templates,这样我就可以在本地的所有repos上有一些预定义的hook。然而,当我尝试运行git init
时,它在目录中找不到模板。如果我通过其他方式指定它,这就不是真的。
[nix-shell:~/tmp/ai-webui/foo]$ git config --global init.templateDir
'/home/abrahms/.git_template/'
[nix-shell:~/tmp/ai-webui/foo]$ git init
warning: templates not found in '/home/abrahms/.git_template/'
Initialized empty Git repository in /home/abrahms/tmp/ai-webui/foo/.git/
[nix-shell:~/tmp/ai-webui/foo]$ git init --template=/home/abrahms/.git_template/
Reinitialized existing Git repository in /home/abrahms/tmp/ai-webui/foo/.git/
[nix-shell:~/tmp/ai-webui/foo]$ export GIT_TEMPLATE_DIR="$HOME/.git_template/"
[nix-shell:~/tmp/ai-webui/foo]$ git init
Reinitialized existing Git repository in /home/abrahms/tmp/ai-webui/foo/.git/
[nix-shell:~/tmp/ai-webui/foo]$ unset GIT_TEMPLATE_DIR
[nix-shell:~/tmp/ai-webui/foo]$ git init
warning: templates not found in '/home/abrahms/.git_template/'
Reinitialized existing Git repository in /home/abrahms/tmp/ai-webui/foo/.git/
[nix-shell:~/tmp/ai-webui/foo]$ git --version
git version 2.40.1
字符串
我希望bar git init
的工作方式就像指定envvar或--template
标志一样。
1条答案
按热度按时间ctzwtxfj1#
看起来你对
init.templateDir
的值加了引号。你不应该在输出中看到这些单引号。例如,如果我运行:字符串
然后运行:
型
我看到输出:
型
不(如你在问题中所示):
型
在我的全局git配置中,我看到:
型