Jacob
Jacob

Reputation: 51

How do I completely delete user info from git terminal?

I created a test git and github account a few days ago. Today I created a new github account and updated my git terminal username and email using git config --global user.name and git config --global user.email commands. But when I push a repo using git push origin master to my new github account, it still appears to use the test git username that I created before and gives me this error:

remote: Permission to github repo url denied to old username.

fatal: unable to access github repo url: The requested URL returned error: 403

I've tried deleting the old user too but nothing works. When I run git config --global --list, it shows my new details.

I've tried a lot of things before posting on here so I really don't know what the problem is. Any help would be greatly appreciated!

Upvotes: 5

Views: 29820

Answers (6)

Shailesh Yadav
Shailesh Yadav

Reputation: 301

I also faced this issue so i had removed name and email from config file by using my_repogit1 shaileshyadaav$ git config --local --unset-all user.nameand after this you can verify details by using git config --list

Upvotes: 3

Sophie Cooperman
Sophie Cooperman

Reputation: 524

I had the same issue, the only thing that worked for me, is manually remove the git credentials save in the control panel: Control Panel → User Accounts → Credential Manager → Windows Credential Manager → erase the github credentials.

Although I tried all the other git commands configurations, this deletion, and then re-entering username and email on push, made it connect to the right account.

Upvotes: 4

Nico Sabbath
Nico Sabbath

Reputation: 31

I've been struggling with an issue of this kind for 2 hours or so, and finnally picked an idea from one of the answers: it was to clean the config file. To do that, I just opened it on an editor (sudo gedit .git/config) and saved the file totally empty. After that, I filled some of the missed info like user.name, user.email. Then, I've made an git init and a git clone , and editted one of the files. When I tried to upload it with the git push origin master it prompted me to enter the credentials (Username and Password), and finally I was able to submit my changes! I hope it helps you and I'm sorry about my English, it's not my native tongue.

Upvotes: 3

Pablo C. García
Pablo C. García

Reputation: 22404

git credential-osxkeychain erase
host=github.com
protocol=https
[Press Return]

Then you can do push, and the terminal is going to answer for new credentials.

From ikaikastine

Upvotes: 6

joker
joker

Reputation: 3752

You need to remove the remote url first and add the new one:

git remote rm origin
git remote add origin <url>

Upvotes: 0

Gustavo Conde
Gustavo Conde

Reputation: 977

Git documentation says:

The first place Git looks for these values is in an /etc/gitconfig file, which contains values for every user on the system and all of their repositories. If you pass the option --system to git config, it reads and writes from this file specifically.

The next place Git looks is the ~/.gitconfig (or ~/.config/git/config) file, which is specific to each user. You can make Git read and write to this file by passing the --global option.

Finally, Git looks for configuration values in the configuration file in the Git directory (.git/config) of whatever repository you’re currently using. These values are specific to that single repository.

Each of these “levels” (system, global, local) overwrites values in the previous level, so values in .git/config trump those in /etc/gitconfig, for instance.

So, maybe you could open .git/config with a text editor and check that your user.email and other variables are what you want them to be.

Upvotes: 1

Related Questions