我已经配置了全局的git用户,但是想要在一个单独的git项目中使用不同的用户。
在该项目中,我使用了git config --local user.name "localuser"
和git config --local user.email "localuser@example.com"
来设置本地项目的用户和电子邮件。
但是,当我尝试推送到github上的远程库时,我会遇到以下错误:
remote: Permission to localuser/repo.git denied to globaluser.
fatal: unable to access 'https://github.com/localuser/repo.git/': The requested URL returned error: 403
以下是一些可能有助于诊断的输出:
git remote -v
:
github https://github.com/localuser/repo.git (fetch)
github https://github.com/localuser/repo.git (push)
git config --list
:
user.name=globaluser
user.email=globaluser@example.com
...
git config --local --list
:
user.name=localuser
user.email=localuser@example.com
...
git config user.name
:
localuser
git rebase -r <last good commit sha> --exec 'git commit --amend --no-edit --reset-author' && git commit && git rebase --continue && git push -f
- dbaltor