鉴于我的电子邮件和用户名包含在 ~/.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)
Remote :
git remote -v
origin https://github.com/<owner>/<repo> (fetch)
origin https://github.com/<owner>/<repo> (push)
最佳答案
这是两个非常不同的数据部分,没有关联
配置中的用户名用于设置提交的作者。
当推送到远程时提示您输入用户名时,这是不同的。这些是身份验证凭据。
Git 不会假定配置的用户名与身份验证凭据用户名相同。
这是一件好事。比如一个很真实的例子:
我在 Git 中配置的用户名:Thomas Stringer
我的 GitHub 用户名:tstringer
如果那是假定的,那对我来说不得不覆盖或重新配置会很烦人。
关于git - "git config -l"显示我的用户名/电子邮件集,但 git push 要求输入用户名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32832388/