我在github上创建了一个repo,在本地设置了repo url,并尝试第一次推送git push origin main
。
它要求我输入密码,但我注意到提示符使用的是我另一个github帐户的用户名。我运行了几个git命令来更改我的凭据,以便我可以成功推送并进行身份验证。
我仍然无法通过密码进行身份验证,但我想我首先解决了这个git问题,因为我觉得我绝望地开枪把自己挖进了一个洞。
首先我改变了我的用户名git config --global credential.username "MyUserName"
git config --global credentials.username "MyUserName"
然后我跑git config --global credential.helper manager
,然后git config --global alias.credential-manager "credential-manager-core"
,现在我尝试推送时收到一条消息,显示为expansion of alias 'credential-manager' failed; 'credential-manager-core' is not a git command git: 'credential-manager-core' is not a git command. See 'git --help'.
。
我还在macOS上删除了Keychain中的github信息。
1条答案
按热度按时间3yhwsihp1#
您的Git客户端用户名和电子邮件都存储在本地用户主目录的文本文件“.gitconfig”中。
在Windows上,这将是(例如)C:\Users\Bob.gitconfig
您可以直接使用您最喜欢的文本编辑器编辑此文件,而不是运行上述命令。
它应该包含这样的内容(替换为您自己的数据):
字符串
如果你想将现有代码推送到GitHub上的一个新的(空的)存储库中,他们详细描述了如何做到这一点。
希望这对你有帮助:-)