如何使用 git config 删除全局配置中的条目?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11868447/
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 14:20:55  来源:igfitidea点击:

How can I remove an entry in global configuration with git config?

git

提问by hatmatrix

I ran a global configuration command in git to exclude certain files using a .gitignore_global file:

我在 git 中运行了一个全局配置命令以使用 .gitignore_global 文件排除某些文件:

git config --global core.excludesfile ~/.gitignore_global

Is there a way to undo the creation of this setting globally?

有没有办法全局撤消此设置的创建?

回答by larsks

I'm not sure what you mean by "undo" the change. You can remove the core.excludesfilesetting like this:

我不确定您所说的“撤消”更改是什么意思。您可以core.excludesfile像这样删除设置:

git config --global --unset core.excludesfile

And of course you can simply edit the config file:

当然,您可以简单地编辑配置文件:

git config --global --edit

...and then remove the setting by hand.

...然后手动删除设置。

回答by Yousry Elwrdany

You can use the --unsetflag of git configto do this like so:

您可以使用--unset标志git config来执行此操作,如下所示:

git config --global --unset user.name
git config --global --unset user.email

If you have more variables for one config you can use:

如果您有一个配置的更多变量,您可以使用:

git config --global --unset-all user.name

回答by Prabhakar Undurthi

Try this from the command line to change the git config details.

从命令行尝试此操作以更改 git 配置详细信息。

git config --global --replace-all user.name "Your New Name"

git config --global --replace-all user.email "Your new email"

回答by Pasan Sumanaratne

Open config file to edit :

打开配置文件进行编辑:

git config --global --edit

Press Insertand remove the setting

按下Insert并删除设置

and finally type :wqand Enterto save.

最后输入:wqEnter保存。

回答by AConsumer

You can check all the config settings using

您可以使用检查所有配置设置

git config --global --list

You can remove the setting for example username

您可以删除设置,例如用户名

git config --global --unset user.name

You can edit the configuration or remove the config setting manually by hand using:

您可以使用以下命令手动编辑配置或删除配置设置:

git config --global --edit 

回答by Angelo Mendes

You can edit the ~/.gitconfigfile in your home folder. This is where all --globalsettings are saved.

您可以编辑~/.gitconfig主文件夹中的文件。这是--global保存所有设置的地方。

回答by Santhosh Kumar HN

git config information will stored in ~/.gitconfigin unix platform.

git 配置信息将存储~/.gitconfig在 unix 平台中。

In Windows it will be stored in C:/users/<NAME>/.gitconfig.

在 Windows 中,它将存储在 C:/users/<NAME>/.gitconfig.

You can edit it manually by opening this files and deleting the fields which you are interested.

您可以通过打开此文件并删除您感兴趣的字段来手动编辑它。