0

I worked a contract gig recently with a temporary email address and username for git repos. It's over now and the temp username seems to be messing up my old personal repositories in git.

When I try to push origin master

I get:

remote: Permission to <my-repo>.git denied to <wrong-username>.

If I look in git config --list I get the proper username and email - I can't seem to find the location of [wrong-username] and I can't get rid of it. How do I connect back to my remote repository and get rid of this old username that I won't be using in the future?

Liam
  • 27,717
  • 28
  • 128
  • 190
user3730529
  • 73
  • 2
  • 8
  • Try looking at the remote `git remote -v`, is the username set here? If so, [change it](https://stackoverflow.com/a/32238628/1790644). Try opening the file at `project_dir/.git/config`, maybe the username is defined there? – Matt Clark Jul 06 '17 at 15:37
  • [This answer](https://stackoverflow.com/a/4220493/542251) covers the various places this is configured quite well. Read the comments as they are relevant – Liam Jul 06 '17 at 15:38
  • Matt Clark, I checked `git remote -v` and all I saw were the paths to fetch and push, no other info. I looked in `.git/config` and there was actually no username or email there. Is there a way to search for this incorrect username? I can't seem to find where it's even set. – user3730529 Jul 06 '17 at 16:38
  • Usernames can be stored globally and per git repo. Verify both `git config user.name` and `git config --global user.name` – spuder Jul 06 '17 at 17:47
  • Yeah, I checked both. I checked global, then i navigated to my project folder and checked local. Both are correct but for some reason, this temporary username is still there and it's not letting me commit or push to master. – user3730529 Jul 06 '17 at 19:09

2 Answers2

3

Did you try the global setup?

$ git config --global user.name "John Doe"
$ git config --global user.email johndoe@example.com
arifCee
  • 509
  • 2
  • 12
  • 1
    Yes, I did. And when I type git config --list, the proper user name and email show up. Then I try to push to my remote repo and I still get access denied for the wrong username. – user3730529 Jul 06 '17 at 16:30
  • These commands also work without the "--global", and just update the settings for the current repo. – itnAAnti Aug 04 '19 at 16:19
0

I found the answer here: Git's famous "ERROR: Permission to .git denied to user"

It's the second answer with five steps. Go to keychain access and delete anything that looks incorrect. That solved my problem.

user3730529
  • 73
  • 2
  • 8