重置git模板路径

3

我正在尝试将git模板路径设置为:

– git config --global commit.template  <path to template>

在第一次尝试中,我输入了错误的路径,无法重新设置路径,我收到以下错误:

warning: commit.template has multiple values
error: cannot overwrite multiple values with a single value
       Use a regexp, --add or --replace-all to change commit.template.

因此,我无法执行git commit编辑: 最初我执行了:
– git config --global commit.template  E:/mygit

我的git只是一个文件夹,我忘记提到文件名了。

下一次我执行的是:

图片描述

欢迎任何关于我的问题的指针。

1个回答

6
您可以使用以下方法删除它:
git config --global --unset-all commit.template

我不确定你是怎么搞出多个值的。当我输入 git config commit.template foo.txt 时,它会覆盖前一个值。

我唯一能重现你的问题的方法是使用 git config --add commit.template foo.txt,这似乎会添加第二个值。

如果你不想使用命令行,你也可以用文本编辑器编辑全局的 git 配置文件。它可能包含以下类型的部分:

[commit]
    template = template2.txt
    template = template.txt

你能否更新你的问题,展示你所执行的确切命令以及该命令的输出结果? - nwinkler
你能试一下我的回答中的 --unset-all 命令吗,@diva?执行该命令会发生什么?它应该会删除所有与该键相关的值,然后你就可以再次设置它了。 - nwinkler
不客气。-all 确实很重要,因为它会删除所有值,而不仅仅是单个值。 - nwinkler
有了这个想法,另一个解决方案也可以使用 replace-all 函数来实现。 - KOTIOS

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接