Reputation: 7152
I have a project which I want to use a different user.name
(leeyuiwah
), which is different to the global value leeyuiwah-sl
), to talk to a certain repo in github.com
. I have already updated the project's .git/config
but then my command got this error
$ git push -u origin master
remote: Permission to leeyuiwah/brti.git denied to leeyuiwah-sl.
fatal: unable to access 'https://github.com/leeyuiwah/brti.git/': The
requested URL returned error: 403
I ran this and the settings seem to be right:
$ git config --list | grep -E -e "user.*name"
credential.username=leeyuiwah
user.name=leeyuiwah
But then I realized I had a config file used by SourceTree
that stored the wrong name
$ find . -type f | xargs grep leeyuiwah-sl
./.git/sourcetreeconfig.json: "Username": "leeyuiwah-sl",
So I think I could just edit that JSON file. I did that but it did not help.
Now I am stuck. Any suggestion?
Update
More info as per comment:
$ git remote show origin
* remote origin
Fetch URL: https://github.com/leeyuiwah/brti.git
Push URL: https://github.com/leeyuiwah/brti.git
HEAD branch: (unknown)
And
$ git config --list --show-origin | grep leeyuiwah
file:.git/config
remote.origin.url=https://github.com/leeyuiwah/brti.git
file:.git/config credential.username=leeyuiwah
file:.git/config user.name=leeyuiwah
file:.git/config [email protected]
Upvotes: 1
Views: 1238
Reputation: 7063
I can only guess, but this was too long for a comment anyway.
My git config --list --show-origin
looks like this
file:"C:\\ProgramData/Git/config" core.symlinks=false
...
file:"C:\\Git\\mingw64/etc/gitconfig" user.name=my name
file:"C:\\Git\\mingw64/etc/gitconfig" [email protected]
file:"C:\\Git\\mingw64/etc/gitconfig" credential.helper=manager
...
file:.git/config branch.master.remote=origin
There are 3 different config files. The last entry if from the local repo. As I am working on windows with only one name, there is only one user.name
, ...
See here for further details.
If you cannot find different user.names
in different config
files in your case, something must be wrong (I guess). In other words I would expect something like
file:"C:\\Git\\mingw64/etc/gitconfig" user.name=my name
...
file:.git/config user.name=my second name
...
I hope that helps...
Upvotes: 1