我用这些命令改变了我的用户和电子邮件git
git config --global user.name "maa"
git config user.email "maa@gmail.com"
Run Code Online (Sandbox Code Playgroud)
我确认了这一变化
git config --global user.name
git config user.email
Run Code Online (Sandbox Code Playgroud)
它显示正确的名称.但是,当我按下旧用户名时使用:
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
Run Code Online (Sandbox Code Playgroud)
在user.name和user.email设置仅用于提交的元数据.
我可以看到你正在使用https传输,所以用户名以某种方式存储.在我看来,有两种选择:
%HOME%/.netrc(%HOME%/_netrc或%HOMEDRIVE%%HOMEPATH%\_netrc在Windows上)https://username@github.com/...),您需要在此处更新.git/config,例如通过发布git remote set-url https://<newusername>@github.com/<newusername>/yourRepo作为一般规则,您可以在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]
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8647 次 |
| 最近记录: |