2016-10-23 73 views
1

我想练习使用我的git bash,但可以切换帐户。无法切换我的git bash帐户

当我输入git config user.name我应该在这里放什么?
那么git config user.email呢?

不需要在任何地方输入我的密码吗?这有点奇怪。所以,问题是,我不能用我的第二个帐户更改推,我得到这个错误:

! [remote rejected] master -> master (permission denied) 
error: failed to push some refs to 'https://github.com 

有我改变了我的帐户或不?我不明白这一点。
如何正确切换帐户?

回答

0

user.nameuser.email无关身份验证(仅适用于犯下作者:见“Why are my commits linked to the wrong user?”)

所有你需要做的‘切换帐户’是修改远程URL

git remote set-url origin https://<secondGitHubAccount>@github.com/<user>/<repo> 

只要secondGitHubAccount<repo>的所有者或合作者,这将起作用。

您可以使用git凭证帮助程序来缓存您的密码(并避免必须输入,每个 Git远程操作)。例如,在Windows上,您将使用manager helper(请参阅“How to sign out in Git Bash console in Windows?”)。