2016-10-28 75 views
0

我在我的电脑上有几个git存储库。每次我推送时,其中一些人会询问我的用户名,而另一些则不会。git配置提示输入用户名

这是为什么?是否有需要更改的全局git配置或设置?

运行linux mint如果它很重要。

+1

可能有些回购使用'https://'远程,而另一些则使用'git @ github.com'远程。还可能有其他原因,但检查并比较'git remote -v'的输出。 – janos

+0

本手册页介绍如何提供凭据以避免重复验证:https://git-scm.com/docs/gitcredentials.html您可以阅读存储密码以供将来使用的凭证助手https:// git-scm .com/docs/git-credential-cache https://git-scm.com/docs/git-credential-store – apk

回答

0

要确保你的git的本地资源库状态,您的git的本地库文件夹类型命令

git config --list 

里面看到受影响的配置。


我们有2个类型的Git配置:

全球(如果使用2个或多于git的服务器,我不推荐这种方式)

git config --global user.name "Mr. Joe" 
git config --global user.email "[email protected]" 


存储库级别(如果您使用许多git服务器,建议),在回购R1:

git config user.name "Mr. Rilcon" 
git config user.email "[email protected]" 

在回购R2:

git config user.name "Mr. Happy" 
git config user.email "[email protected]" 

然后你会避免出现问题,Git会不会问你的用户名和密码多次。

1

听起来就像您的某些存储库正在从凭证存储中提取凭据。如果你从git文档检查下面的例子,你可以看到如何为每个回购存储它。 example below from git-credential-store documentation

$ git config credential.helper store 
$ git push http://example.com/repo.git 
Username: <type your username> 
Password: <type your password> 

[several days later] 
$ git push http://example.com/repo.git 
[your credentials are used automatically]