2015-09-28 59 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> 
相關問題