OSX – CLI git pushes with wrong username
by Riley MacDonald, June 11, 2017
Issue:
$ git push -u origin "#132" remote: Permission to silencecm/Cuckoo.git denied to rileymacdonald. fatal: unable to access 'https://github.com/silencecm/Cuckoo.git/': The requested URL returned error: 403 |
While trying to push to a repository I found git was attempting to use the wrong username. I attempted to update the global and local git config files but the issue was still reproducible. Turns out xcode caches the git credentials aggressively.
Solution:
- Open the keychain access (start spotlight using cmd + space, type keychain, press enter).
- Under keychains on the upper left, select “login” Under category on the left, select “passwords”.
- Select “github.com” and delete it.
Success! Git now requests a username and password upon pushing:
$ git push -u origin "#132" Username for 'https://github.com': silencecm Password for 'https://silencecm@github.com': Counting objects: 4, done. Delta compression using up to 4 threads. Compressing objects: 100% (4/4), done. Writing objects: 100% (4/4), 390 bytes | 0 bytes/s, done. Total 4 (delta 3), reused 0 (delta 0) remote: Resolving deltas: 100% (3/3), completed with 3 local objects. To https://github.com/silencecm/Cuckoo.git * [new branch] #132 -> #132 Branch #132 set up to track remote branch #132 from origin. |