Git:我不小心更改了配置参数后如何重置它?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16781113/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 16:15:24  来源:igfitidea点击:

Git: How can I reset a config parameter after I have accidentally changed it?

git

提问by Dan Ross

I was exploring the git configoptions using tab completion in bash, and without really thinking, I did this:

我正在git configbash 中使用制表符完成探索选项,并没有真正考虑,我这样做了:

git config --global user.signingkey --help

and now my global signing key is set to --help. Facepalm. Is there a generic way to find out what these config settings where in the past, or is there somewhere that I could look in a project to see what this might have been set to? I have a Github account, maybe I could get the old value from there, since I haven't pushed anything since the mistake? I'm not even sure if it was set to anything, but I do use SSH with Github.

现在我的全局签名密钥设置为--help. 面掌。有没有一种通用的方法来找出这些配置设置在过去的位置,或者有什么地方可以让我在项目中查看它可能被设置为什么?我有一个 Github 帐户,也许我可以从那里获得旧值,因为自从错误以来我没有推送任何东西?我什至不确定它是否设置为任何内容,但我确实在 Github 上使用了 SSH。

cd <another project's location>; git config user.signingkey

returns --help.

返回--help

回答by mvp

Command

命令

git config --global section.key value

does nothing more than editing file ~/.gitconfigwith content like this:

只不过是编辑~/.gitconfig具有以下内容的文件:

[section]
key = value

So, you can simply edit this file and fix it.

因此,您可以简单地编辑此文件并修复它。

Also, you can use command to remove offending setting:

此外,您可以使用命令删除违规设置:

git config --global --unset section.key