git 我的旧用户名仍在使用中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39944469/
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
my old username is still in use
提问by MAS
I have changed my user and email for git with those commands
我已经使用这些命令更改了 git 的用户和电子邮件
git config --global user.name "maa"
git config user.email "[email protected]"
I confirmed the change with
我确认了更改
git config --global user.name
git config user.email
and it shows the right names. However when I push the old user name is used:
它显示了正确的名称。但是,当我推送旧用户名时使用:
git push -u origin master
remote: Permission to maa/brain.git denied to old_user_name.
fatal: unable to access 'https://github.com/maa/brain.git/': The requested URL returned error: 403
回答by MrTux
The user.name
and user.email
settings are only used for commit meta data.
在user.name
和user.email
设置仅用于提交的元数据。
As I can see you are using https transport, so the username is stored somehow. To my mind there are two options:
正如我所看到的,您正在使用 https 传输,因此以某种方式存储了用户名。在我看来,有两种选择:
- You are using
%HOME%/.netrc
(%HOME%/_netrc
or%HOMEDRIVE%%HOMEPATH%\_netrc
on Windows) - Your username is included in the push-url (like
https://[email protected]/...
), here you need to update.git/config
, e.g. by issuinggit remote set-url https://<newusername>@github.com/<newusername>/yourRepo
- You are using a git credential helper. Here it depends which one you use (and maybe which OS you use, see for Windows, Mac OS X).
- 您正在使用
%HOME%/.netrc
(%HOME%/_netrc
或%HOMEDRIVE%%HOMEPATH%\_netrc
在 Windows 上) - 您的用户名包含在 push-url 中(如
https://[email protected]/...
),在这里您需要更新.git/config
,例如通过发出git remote set-url https://<newusername>@github.com/<newusername>/yourRepo
- 您正在使用 git 凭证助手。这取决于您使用的是哪一个(也许您使用的是哪个操作系统,请参阅 Windows、Mac OS X)。
As a general rule you can try the following on the CLI (based on 2), where you replace $credentialhelper
with your credential-helper (you can find it using git config credential.helper
, for Mac OS X it is likely osxkeychain
on Windows it might be wincred
or manager
):
作为一般规则,您可以在 CLI(基于2)上尝试以下操作,在其中替换$credentialhelper
为您的凭证助手(您可以使用 找到它git config credential.helper
,对于 Mac OS X,它可能osxkeychain
在 Windows 上可能是wincred
或manager
):
$ git credential-$credentialhelper erase
host=github.com
protocol=https
[Press Return]