假设我的电子邮件和用户名都包含在~/.gitconfig文件中:
$cat ~/.gitconfig
[user]
name = MyFirst MyLast
email = myemail@gmail.com
而git config -l
“看到”它们:
$git config -l
user.name=MyFirst MyLast
user.email=myemail@gmail.com
为什么
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)
~/.gitconfig
中的名字与你的GitHub用户名相同。Git软件是一个独立于GitHub网站的东西。我建议将SSH密钥添加到您的GitHub帐户中,这样您就不必每次推送时输入用户名/密码。 - Adrian