我如何“登录”到 git?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/56573522/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I "login" to git?
提问by
I need to change who git thinks I am so I can push to a different repo ( both are mine. ).
我需要改变 git 认为我是谁,以便我可以推送到不同的 repo(两者都是我的。)。
Here is a similar issuebut I don't want to set any config variables.
这是一个类似的问题,但我不想设置任何配置变量。
I just want to login once to my current username. I plan on deleting my other account.
我只想用我当前的用户名登录一次。我打算删除我的另一个帐户。
Here is the error when I attempt a git push origin master
这是我尝试时的错误 git push origin master
remote: Permission to current_user/fav-front.git denied to user_to_delete. fatal: unable to access 'https://github.com/current_user/repo.git/': The requested URL returned error: 403
远程:对 current_user/fav-front.git 的权限被拒绝给 user_to_delete。致命:无法访问“ https://github.com/current_user/repo.git/”:请求的 URL 返回错误:403
Please note that the git config variables for user and email ( user.name and user.email ) are not related to the authentication that git push
uses.
请注意,用户和电子邮件( user.name 和 user.email )的 git 配置变量与使用的身份验证无关git push
。
They are used for commits.
它们用于提交。
To reiterate, I want to login to git as current user.
重申一下,我想以当前用户身份登录 git。
采纳答案by VonC
You don't login to Git.
您没有登录 Git。
You do login to a Git repository hosting server, which request an authentication, but Git itself has no authentication nor authorization.
您确实登录到 Git 存储库托管服务器,该服务器请求身份验证,但 Git 本身没有身份验证或授权。
What Git does have is credential caching (check the output of git config credential helper
).
On Mac: "Updating credentials from the OSX Keychain": you can check if your old user was stored there, and update it.
Git 具有的是凭据缓存(检查 的输出git config credential helper
)。
在 Mac 上:“从 OSX 钥匙串更新凭据”:您可以检查您的旧用户是否存储在那里,并更新它。
If you really want to disable the credential helper, you will be asked your credentials every time you push to a repository hosted on a server requesting authentication.
如果您真的想禁用凭证助手,则每次推送到请求身份验证的服务器上托管的存储库时,系统都会询问您的凭证。