git init & templates not being found

uqjltbpv  于 5个月前  发布在  Git
关注(0)|答案(1)|浏览(41)

我尝试使用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标志一样。

ctzwtxfj

ctzwtxfj1#

看起来你对init.templateDir的值加了引号。你不应该在输出中看到这些单引号。例如,如果我运行:

git config --global init.templateDir ~/.config/git/templates

字符串
然后运行:

git config --global init.templateDir


我看到输出:

/home/lars/.config/git/templates


不(如你在问题中所示):

'/home/lars/.config/git/templates'


在我的全局git配置中,我看到:

[init]
    templateDir = /home/lars/.config/git/templates

相关问题