Git pushes from the wrong user from the terminal

I have a problem with git and my terminal.

Here is a gallery to show you my problem: http://imgur.com/a/6RrEY

When I click on my terminal, git says that I click on them with a different username, that the user from my organization (my company) is without committing at all and it seems that he doesn’t belong to anyone: (check the pic gallery first)

But this does not happen when I use Github for mac, in the feed I see that the commits I made.

The problem also affects my personal repositories, my terminal says that I don’t have permission to impose commits on these repositories (which is obviously wrong), because it is trying to push it with this user: (check gallery second pic.)

Guess what? This does not happen with github for mac either.

I redid my computer to a new one a few days ago, so I reset 'created all my github ssh key and left only the new one created by Github for Mac, so I don’t think that there is some kind of ghost user key / ssh hidden somewhere- then this hdd is brand new: (check the gallery of the third picture)

My .gitconfig file is clear, it only has my credentials: (check gallery fourth pic.)

I really don't understand, help, StackOverflow, you are the only hope.

(My apologies for my poor Gimp skills and a link to Star Wars)

EDIT: ssh-add -l only shows a good ssh key generated by github for mac and I only have one github account

EDIT2: ssh -T git@github.com recognize me as a good user.

EDIT3: After several tests, it looks like my terminal does with my username, but pushes them to others, Github for mac commits and pushes with a good username. This situation happens with every i / make repo (even new ones).

EDIT4: My git log --pretty="%h %an %ae" personal repository shows my good username

EDIT5: No sign of environment variables that would override my credentials in my env . Even if I try to set these variables with a good account, the problem persists.

EDIT6: Everything works fine if I force the user to the /.git/config repository path, but I don't think a good option: http://USER@github.com/USER/REPO.git

EDIT7: We removed the git user who moved the commits for me, and this causes another error: remote: Invalid username or password. fatal: Authentication failed for 'https://github.com/USER/REPO.git/' remote: Invalid username or password. fatal: Authentication failed for 'https://github.com/USER/REPO.git/'

FINAL EDIT: I installed git using homebrew, typed git config --global push.default simple , and now it accepts my credentials even without forcing the user. This is strange. Thank you all for your help, you are great guys!

+91
git github ssh
Feb 06 '14 at 22:27
source share
16 answers

Despite all the great options other users set, the only way to fix this is to reinstall git completely and type git config --global push.default simple to rewrite the good credentials.

+15
Mar 12 '14 at 8:35
source share

I just had this problem at work. The built-in git that comes with mac or comes when you install xcode caches git credentials in the keychain. The fix for me was:

start access to keychain (start the spotlight through cmd + space, type keychain, press enter)

Under the key chains in the upper left corner, select "login" Under the category on the left, select "passwords"

find the name "github" and delete it.

+141
Jun 10 '14 at 0:10
source share

github identifies you by the ssh key that it sees, and not by the settings from git.

Therefore, you need to make sure that the ssh key of your work account is not in your keychain when you try to delete from your personal account, and vice versa.

Use ssh-add -l to determine which keys are in your ssh-add -l keys, and ssh-add -d <keyfile> to remove a key from your key set, if it doesn’t work, remove the “unwanted” ssh key from ~/.ssh/config .

source

NB. Github will still only identify your commit based on the email.

+25
Sep 11 '16 at 22:34
source share

it looks like my terminal commits with my username, but pushes them to others

The name of the author and committer, as well as the email address (which are important for GitHub) are obtained from:

 git config user.name git config user.email 

However, as mentioned in git config and git commit-tree , these values ​​can be overridden by environment variables:

 GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL 

So double-check these variables.

Everything works fine if I force the user .git/config into the .git/config repository, but I don't think this is a good option.

But that should be a good solution.
When using an https address, I always specify the user in it to make sure that authentication is performed with the correct user.

 http://USER@github.com/USER/REPO.git 
+11
Feb 07 '14 at 7:35
source share

The killall ssh-agent workaround is executed first, then add the ssh keys generated for the account you should use ssh-add ~/.ssh/id_4shameer

This will help us work with multiple github accounts when we get an error like ERROR: Permission to user/repo-git.git denied to username.

+8
Nov 02 '16 at 8:44
source share

If you are using a MAC, go to Key Access and delete the user account for which you do not want to receive git.

+7
May 15 '16 at 4:04
source share

I am using Windows 10 and I ran into the same problem today. In my case, my credentials for another user were saved by the Windows credential manager. Thus, deleting / deleting git credentials with the following command, git config --global --unset credential.helper

did not help I had to manually delete the entry in Windows, following the path below,

Start → Control Panel ---> User Accounts ---> Credential Management ---> Windows Credentials

Then find the entry, for example, git: https://github.com and delete it. After that, everything works fine.

+4
Mar 02 '19 at 13:21
source share

The solution for me was to add an entry to my ~ / .ssh / config file for github. I had to do this because:

  1. I had multiple github accounts with the same key (don't do this!)
  2. when you execute the git push command using ssh, your computer grabs id_rsa by default and uses it as the ssh identifier.
  3. github cannot (unsurprisingly) reflect the conflict you have in mind, since it bases an account on a key that it represents, that if it is tied to multiple accounts, it will lead to such pain. Killer, for a long time, I get away with it, and everything just works.

The entry I added:

 Host github.com Hostname github.com Port 22 User waterproofpatch IdentityFile ~/.ssh/id_rsa_waterproofpatch 

I created a new key unique to my account as id_rsa_waterproofpatch. This entry in my ssh configuration indicates that for connections to github.com I want to provide this key.

Another solution would probably be for me to log in to another account, delete a duplicate SSH key.

+3
May 2 '18 at 4:22
source share

clearing the keychain did not help ... I had to ssh-add -D and re-add the key using ssh-add <keyfile>

0
May 03 '18 at 15:39
source share

I solved this problem by deleting (or renaming * .bak) the id_rsa and id_rsa.pub files on MacOS High Sierra. The idea is from here .

I have custom host redirects in ~ / .ssh / config that should be applied, but I used the wrong user before I renamed two files ...

0
Jul 18 '18 at 12:19
source share

Here's what worked for me:

  1. Change credentials inside .git-credentials
  2. Changing global user.name and user.email inside .gitconfig
0
Sep 10 '18 at 15:32
source share

Go to the Windows credential manager in the control panel, and there you can find the credentials of your Github account, and there you can edit the username and password. After completing these steps, click on the code again and your code will be added to your current Github account.

0
Jan 22 '19 at 12:49
source share

What worked for me by deleting the repo and adding it again:

 git remote rm origin git remote add origin git@github.com:fguillen/MyApp.git 
0
Jan 26 '19 at 14:36
source share

I have the same problem in windows10 even after deleting my git, since @ user542833 says that this is because the Windows cache and you have to delete the Github credentials in your Credential Manager and when you try to click again, Windows asks for your credentials and sets it again

0
Mar 05 '19 at 13:04 on
source share

What helped me was to use the https Github repo address instead of the ssh url. I went to the Github project page and copied the https URL to the clipboard, and then pasted it into the second command below:

 git remote rm origin git remote add origin https://[...] 
0
Jun 14 '19 at 18:34
source share

I had a similar problem, and it turned out that the problem was that the public key file contained my email address on the last line. This seemed to override the user setting in my configuration. As soon as I deleted my email from the .pub file (and re-uploaded it to the repository), Git connected using the correct user.

0
Jun 18 '19 at 8:26
source share



All Articles