2015-09-28 124 views
2

鉴于我的电子邮件和用户名包含在〜/的.gitconfig:“混帐配置-l”显示我的用户名/电子邮件设置,但混帐推询问用户名

$cat ~/.gitconfig 
[user] 
    name = MyFirst MyLast 
    email = [email protected] 

而且git config -l“看到”他们:

$git config -l 
user.name=MyFirst MyLast 
[email protected] 

为什么git push不是看到他们?

$git push origin master 
Username for 'https://github.com': 

这里有点更多的信息:

状态:

git status 
On branch master 
Your branch is based on 'origin/master', but the upstream is gone. 
    (use "git branch --unset-upstream" to fixup) 
Untracked files: 
    (use "git add <file>..." to include in what will be committed) 

遥控器:

git remote -v 
origin https://github.com/<owner>/<repo> (fetch) 
origin https://github.com/<owner>/<repo> (push) 
+0

Git并不认为'〜/ .gitconfig'中的您的名字与您的github用户名相同。 git软件与github网站是分开的。我建议将SSH密钥添加到您的github帐户,以便您不必在每次推送时输入用户名/密码。 – Adrian

回答

3

这些都是不相关的两个非常不同的数据部分

配置中的用户名用于设置提交的作者等。

当推送到远程时系统提示您输入用户名,这是不同的。这些是身份验证凭证。

Git不认为配置的用户名与认证凭证用户名相同。

这是一件好事。举例来说,一个很现实的例子:

Git中我配置用户名:Thomas Stringer

GitHub上的用户名tstringer

如果假设,那将是对我来说很烦人必须重写或重新配置。

+1

是的我一直忘记使用ssh(与〜/ .ssh/config一起使用)。 'git remote set-url origin ssh://[email protected]/ /' – javadba

1

这是更多的是评论/添加答案(这将被接受)的@Thomas斯金格:

来处理这个问题的方法是对我们的SSH(与的〜/ .ssh/config中联) 。

git remote set-url origin ssh://[email protected]/<owner>/<repo> 
相关问题