从 Git 存储库中删除用户名
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6243407/
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
Delete username from a Git repository
提问by shannoga
I am getting this warning when I try to set my user name in Tower:
当我尝试在Tower 中设置我的用户名时收到此警告:
warning: user.name has multiple values
警告:user.name 有多个值
I have checked in a terminal window and found that I have three usernames:
我检查了一个终端窗口,发现我有三个用户名:
macmini:HiBye shannoga$ git config --get-all user.name
Shani
shani
shani
How can I delete two of the user names?
如何删除两个用户名?
回答by svick
Use git config -e
and you should see something like:
使用git config -e
,您应该会看到如下内容:
[user]
name = Shani
name = shani
name = shani
Delete the lines you don't want.
删除不需要的行。
回答by Aesch
This worked for me on my Mac:
这在我的 Mac 上对我有用:
git config --global --unset-all user.name
回答by Dexter
If you want to replace the wrong ones with the proper one:
如果你想用正确的替换错误的:
git config --global --replace-all user.name "FName LName"
same applies for user mail:
同样适用于用户邮件:
git config --global --replace-all user.mail "[email protected]"
回答by VonC
Note: with git1.8.1rc1(December 2012), the logic is different;
注意:与git1.8.1rc1(2012年12月),逻辑不同;
"
git config --get
" used to diagnose presence of multiple definitions of the same variable in the same configuration file as an error, but it now applies the "last one wins" rule used by the internal configuration logic.Strictly speaking, this may be an API regression but it is expected that nobody will notice it in practice.
“
git config --get
”用于将同一配置文件中同一变量的多个定义的存在诊断为错误,但它现在应用内部配置逻辑使用的“最后一个获胜”规则。严格来说,这可能是 API 回归,但预计在实践中没有人会注意到它。
回答by Tom Taylor
If updating email address and password in your config file didn't help then probably you might be using this account with your machine for the first time. Generating and assosiating the pass phrase key with your account helps.
如果在您的配置文件中更新电子邮件地址和密码没有帮助,那么您可能是第一次在您的机器上使用此帐户。生成密码并将其与您的帐户相关联会有所帮助。
Reference:
参考:
https://help.github.com/en/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agenthttps://kbroman.org/github_tutorial/pages/init.html
https://help.github.com/en/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent https://kbroman.org/github_tutorial/pages/init .html
Cheers !
干杯!
回答by Marcelo
The above answers didn't work for me. Edit the .gitconfig file in your home directory. This is your global configuration.
以上答案对我不起作用。编辑主目录中的 .gitconfig 文件。这是您的全局配置。
cd ~
edit .gitconfig
编辑 .gitconfig
[user]
name = Your Name
email = [email protected]
回答by DriveItLikeYouStoleIt
The older answers above didn't work for me either anymore: in addition to editing the .gitconfig file directly, you can just run
上面的旧答案对我也不再适用:除了直接编辑 .gitconfig 文件之外,您还可以运行
git config --global --edit
and make your changes there.
并在那里进行更改。