git pushes with wrong user from terminalRemove credentials from GitGit pushing to remote GitHub repository as wrong usergit push is pushing to the wrong repoGitHub push still in my old accountHow to remove local (untracked) files from the current Git working tree?How to clone all remote branches in Git?What is the difference between 'git pull' and 'git fetch'?How to undo 'git add' before commit?How do I undo the most recent local commits in Git?How do I check out a remote Git branch?How do I delete a Git branch locally and remotely?Undo a Git merge that hasn't been pushed yetHow to revert a Git repository to a previous commitHow do I rename a local Git branch?

Do Rabbis admit emotional involvement in their rulings?

Are wands in any sort of book going to be too much like Harry Potter?

Why is it wrong to *implement* myself a known, published, widely believed to be secure crypto algorithm?

Which types of fruit can I give to my dog?

Compactness in normed vector spaces.

Double underlining a result in a system of equations with calculation steps on the right side

Are on’yomi words loanwords?

Passport stamps art, can it be done?

Can I bring back Planetary Romance as a genre?

Origins of the "array like" strings in BASIC

Which spells are in some way related to shadows or the Shadowfell?

Can a planet still function with a damaged moon?

What dice to use in a game that revolves around triangles?

How do I minimise waste on a flight?

Why do 3D printers have only one limit switch?

What replaces x86 intrinsics for C when Apple ditches Intel CPUs for their own chips?

Company stopped paying my salary. What are my options?

Row vectors and column vectors (Mathematica vs Matlab)

if i accidentally leaked my schools ip address and someone d doses my school am i at fault

how to find out if there's files in a folder and exit accordingly (in KSH)

Was there a contingency plan in place if Little Boy failed to detonate?

How to avoid making self and former employee look bad when reporting on fixing former employee's work?

Lorentz invariance of Maxwell's equations in matter

Using wilcox.test() and t.test() in R yielding different p-values



git pushes with wrong user from terminal


Remove credentials from GitGit pushing to remote GitHub repository as wrong usergit push is pushing to the wrong repoGitHub push still in my old accountHow to remove local (untracked) files from the current Git working tree?How to clone all remote branches in Git?What is the difference between 'git pull' and 'git fetch'?How to undo 'git add' before commit?How do I undo the most recent local commits in Git?How do I check out a remote Git branch?How do I delete a Git branch locally and remotely?Undo a Git merge that hasn't been pushed yetHow to revert a Git repository to a previous commitHow do I rename a local Git branch?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








86















I have an issue with git and my terminal.



Here's a gallery to show you my issue : http://imgur.com/a/6RrEY



When I push commits from my terminal, git says I push them with another username, that's a user from my organisation (my company) with no commit at all and it seems it belongs to no one : (check gallery first pic)



But this doesn't happen when I use Github for mac, in the feed I see the commits pushed by myself.



The problem also affects my personal repositories, my terminal says that I don't have the permission to push commits on those repositories (which is obviously wrong) since it tries to push it with this user : (check gallery second pic)



Guess what ? This doesn't happen with Github for mac too.



I changed my computer to a brand new one few days ago, so I reset'ed all my ssh key of github and left only a new one generated by Github for Mac so I don't think that there's some ghost user/ssh key hidden somewhere, this hdd is brand new : (check gallery third pic)



My .gitconfig file is all clear, there's only my credentials : (check gallery fourth pic)



I really don't get it, help, StackOverflow, you're my only hope.



(My apologies for my poor Gimp skills and the Star Wars reference)



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



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



EDIT3 : After a few tests it looks like my terminal does the commits with my username, but pushes them with the other one, Github for mac commits and pushes with the good username.This situation happen with every repo I have/make (even new ones).



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



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



EDIT6 : Things work back normally if I force the user in the path of /.git/config of a repository but I don't think that's the good option : http://USER@github.com/USER/REPO.git



EDIT7 : We deleted the git user that pushed the commits for me and this brings another error : remote: Invalid username or password. fatal: Authentication failed for 'https://github.com/USER/REPO.git/'



FINAL EDIT : I installed git with homebrew, typed git config --global push.default simple and now it takes my credentials even without forceing the user. That's strange. Thanks everybody for your help, you're great guys !










share|improve this question



















  • 2





    check ~/.gitconfig and $project_root/.git/config files. One of those two is surely misconfigured for user name.

    – mu 無
    Feb 6 '14 at 22:31







  • 1





    Thanks for your answer ansh0l. ~/.gitconfig is clear and so is $project_root/.git/config. In fact I have this issue with every personal project, work projects can be pushed since this other user belongs to my organisation that owns those repositories.

    – Yinfei
    Feb 6 '14 at 22:34












  • Do you have multiple github accounts then? One for company, the other for personal usage?

    – mu 無
    Feb 6 '14 at 22:36











  • Nope, only one for everything.

    – Yinfei
    Feb 6 '14 at 22:36






  • 1





    An annoying solution would be to just regenerate another SSH key. If you are using your current SSH key with another service it would be pointless.

    – Eduardo Bautista
    Feb 6 '14 at 22:40

















86















I have an issue with git and my terminal.



Here's a gallery to show you my issue : http://imgur.com/a/6RrEY



When I push commits from my terminal, git says I push them with another username, that's a user from my organisation (my company) with no commit at all and it seems it belongs to no one : (check gallery first pic)



But this doesn't happen when I use Github for mac, in the feed I see the commits pushed by myself.



The problem also affects my personal repositories, my terminal says that I don't have the permission to push commits on those repositories (which is obviously wrong) since it tries to push it with this user : (check gallery second pic)



Guess what ? This doesn't happen with Github for mac too.



I changed my computer to a brand new one few days ago, so I reset'ed all my ssh key of github and left only a new one generated by Github for Mac so I don't think that there's some ghost user/ssh key hidden somewhere, this hdd is brand new : (check gallery third pic)



My .gitconfig file is all clear, there's only my credentials : (check gallery fourth pic)



I really don't get it, help, StackOverflow, you're my only hope.



(My apologies for my poor Gimp skills and the Star Wars reference)



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



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



EDIT3 : After a few tests it looks like my terminal does the commits with my username, but pushes them with the other one, Github for mac commits and pushes with the good username.This situation happen with every repo I have/make (even new ones).



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



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



EDIT6 : Things work back normally if I force the user in the path of /.git/config of a repository but I don't think that's the good option : http://USER@github.com/USER/REPO.git



EDIT7 : We deleted the git user that pushed the commits for me and this brings another error : remote: Invalid username or password. fatal: Authentication failed for 'https://github.com/USER/REPO.git/'



FINAL EDIT : I installed git with homebrew, typed git config --global push.default simple and now it takes my credentials even without forceing the user. That's strange. Thanks everybody for your help, you're great guys !










share|improve this question



















  • 2





    check ~/.gitconfig and $project_root/.git/config files. One of those two is surely misconfigured for user name.

    – mu 無
    Feb 6 '14 at 22:31







  • 1





    Thanks for your answer ansh0l. ~/.gitconfig is clear and so is $project_root/.git/config. In fact I have this issue with every personal project, work projects can be pushed since this other user belongs to my organisation that owns those repositories.

    – Yinfei
    Feb 6 '14 at 22:34












  • Do you have multiple github accounts then? One for company, the other for personal usage?

    – mu 無
    Feb 6 '14 at 22:36











  • Nope, only one for everything.

    – Yinfei
    Feb 6 '14 at 22:36






  • 1





    An annoying solution would be to just regenerate another SSH key. If you are using your current SSH key with another service it would be pointless.

    – Eduardo Bautista
    Feb 6 '14 at 22:40













86












86








86


39






I have an issue with git and my terminal.



Here's a gallery to show you my issue : http://imgur.com/a/6RrEY



When I push commits from my terminal, git says I push them with another username, that's a user from my organisation (my company) with no commit at all and it seems it belongs to no one : (check gallery first pic)



But this doesn't happen when I use Github for mac, in the feed I see the commits pushed by myself.



The problem also affects my personal repositories, my terminal says that I don't have the permission to push commits on those repositories (which is obviously wrong) since it tries to push it with this user : (check gallery second pic)



Guess what ? This doesn't happen with Github for mac too.



I changed my computer to a brand new one few days ago, so I reset'ed all my ssh key of github and left only a new one generated by Github for Mac so I don't think that there's some ghost user/ssh key hidden somewhere, this hdd is brand new : (check gallery third pic)



My .gitconfig file is all clear, there's only my credentials : (check gallery fourth pic)



I really don't get it, help, StackOverflow, you're my only hope.



(My apologies for my poor Gimp skills and the Star Wars reference)



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



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



EDIT3 : After a few tests it looks like my terminal does the commits with my username, but pushes them with the other one, Github for mac commits and pushes with the good username.This situation happen with every repo I have/make (even new ones).



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



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



EDIT6 : Things work back normally if I force the user in the path of /.git/config of a repository but I don't think that's the good option : http://USER@github.com/USER/REPO.git



EDIT7 : We deleted the git user that pushed the commits for me and this brings another error : remote: Invalid username or password. fatal: Authentication failed for 'https://github.com/USER/REPO.git/'



FINAL EDIT : I installed git with homebrew, typed git config --global push.default simple and now it takes my credentials even without forceing the user. That's strange. Thanks everybody for your help, you're great guys !










share|improve this question
















I have an issue with git and my terminal.



Here's a gallery to show you my issue : http://imgur.com/a/6RrEY



When I push commits from my terminal, git says I push them with another username, that's a user from my organisation (my company) with no commit at all and it seems it belongs to no one : (check gallery first pic)



But this doesn't happen when I use Github for mac, in the feed I see the commits pushed by myself.



The problem also affects my personal repositories, my terminal says that I don't have the permission to push commits on those repositories (which is obviously wrong) since it tries to push it with this user : (check gallery second pic)



Guess what ? This doesn't happen with Github for mac too.



I changed my computer to a brand new one few days ago, so I reset'ed all my ssh key of github and left only a new one generated by Github for Mac so I don't think that there's some ghost user/ssh key hidden somewhere, this hdd is brand new : (check gallery third pic)



My .gitconfig file is all clear, there's only my credentials : (check gallery fourth pic)



I really don't get it, help, StackOverflow, you're my only hope.



(My apologies for my poor Gimp skills and the Star Wars reference)



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



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



EDIT3 : After a few tests it looks like my terminal does the commits with my username, but pushes them with the other one, Github for mac commits and pushes with the good username.This situation happen with every repo I have/make (even new ones).



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



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



EDIT6 : Things work back normally if I force the user in the path of /.git/config of a repository but I don't think that's the good option : http://USER@github.com/USER/REPO.git



EDIT7 : We deleted the git user that pushed the commits for me and this brings another error : remote: Invalid username or password. fatal: Authentication failed for 'https://github.com/USER/REPO.git/'



FINAL EDIT : I installed git with homebrew, typed git config --global push.default simple and now it takes my credentials even without forceing the user. That's strange. Thanks everybody for your help, you're great guys !







git github ssh






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 7 '14 at 13:24







Yinfei

















asked Feb 6 '14 at 22:27









YinfeiYinfei

6111613




6111613







  • 2





    check ~/.gitconfig and $project_root/.git/config files. One of those two is surely misconfigured for user name.

    – mu 無
    Feb 6 '14 at 22:31







  • 1





    Thanks for your answer ansh0l. ~/.gitconfig is clear and so is $project_root/.git/config. In fact I have this issue with every personal project, work projects can be pushed since this other user belongs to my organisation that owns those repositories.

    – Yinfei
    Feb 6 '14 at 22:34












  • Do you have multiple github accounts then? One for company, the other for personal usage?

    – mu 無
    Feb 6 '14 at 22:36











  • Nope, only one for everything.

    – Yinfei
    Feb 6 '14 at 22:36






  • 1





    An annoying solution would be to just regenerate another SSH key. If you are using your current SSH key with another service it would be pointless.

    – Eduardo Bautista
    Feb 6 '14 at 22:40












  • 2





    check ~/.gitconfig and $project_root/.git/config files. One of those two is surely misconfigured for user name.

    – mu 無
    Feb 6 '14 at 22:31







  • 1





    Thanks for your answer ansh0l. ~/.gitconfig is clear and so is $project_root/.git/config. In fact I have this issue with every personal project, work projects can be pushed since this other user belongs to my organisation that owns those repositories.

    – Yinfei
    Feb 6 '14 at 22:34












  • Do you have multiple github accounts then? One for company, the other for personal usage?

    – mu 無
    Feb 6 '14 at 22:36











  • Nope, only one for everything.

    – Yinfei
    Feb 6 '14 at 22:36






  • 1





    An annoying solution would be to just regenerate another SSH key. If you are using your current SSH key with another service it would be pointless.

    – Eduardo Bautista
    Feb 6 '14 at 22:40







2




2





check ~/.gitconfig and $project_root/.git/config files. One of those two is surely misconfigured for user name.

– mu 無
Feb 6 '14 at 22:31






check ~/.gitconfig and $project_root/.git/config files. One of those two is surely misconfigured for user name.

– mu 無
Feb 6 '14 at 22:31





1




1





Thanks for your answer ansh0l. ~/.gitconfig is clear and so is $project_root/.git/config. In fact I have this issue with every personal project, work projects can be pushed since this other user belongs to my organisation that owns those repositories.

– Yinfei
Feb 6 '14 at 22:34






Thanks for your answer ansh0l. ~/.gitconfig is clear and so is $project_root/.git/config. In fact I have this issue with every personal project, work projects can be pushed since this other user belongs to my organisation that owns those repositories.

– Yinfei
Feb 6 '14 at 22:34














Do you have multiple github accounts then? One for company, the other for personal usage?

– mu 無
Feb 6 '14 at 22:36





Do you have multiple github accounts then? One for company, the other for personal usage?

– mu 無
Feb 6 '14 at 22:36













Nope, only one for everything.

– Yinfei
Feb 6 '14 at 22:36





Nope, only one for everything.

– Yinfei
Feb 6 '14 at 22:36




1




1





An annoying solution would be to just regenerate another SSH key. If you are using your current SSH key with another service it would be pointless.

– Eduardo Bautista
Feb 6 '14 at 22:40





An annoying solution would be to just regenerate another SSH key. If you are using your current SSH key with another service it would be pointless.

– Eduardo Bautista
Feb 6 '14 at 22:40












13 Answers
13






active

oldest

votes


















140














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



start keychain access (start spotlight via cmd + space, type keychain, press enter)



Under keychains on the upper left, select "login"
Under category on the left, select "passwords"



find the name "github" and delete it.






share|improve this answer


















  • 2





    Make sure you delete all github entry here & set the login configuration *git config --global user.name <name> *git config --global user.email <email>

    – Shank_Transformer
    Mar 9 '15 at 8:07












  • In my case, SourceTree was experiencing this problem. Deleting the item in the keychain fixed it!

    – Shoerob
    May 1 '15 at 19:00






  • 1





    @Shank_Transformer your solution worked for me! Thank you!

    – Nazariy1995
    May 3 '16 at 19:22











  • You may have to search for (or launch directly) seahorse on Ubuntu.

    – caw
    Jun 11 '17 at 23:13






  • 3





    I am in debt to you sir

    – Baconbeastnz
    Mar 5 '18 at 10:08


















23














github identifies you by the ssh key it sees, not by any setting from git.



Therefore, you need to ensure that your work account's ssh key is not in your keyring when you try to push from your personal account and vice versa.



Use ssh-add -l to determine which keys are in your keyring, and ssh-add -d <keyfile> to remove a key from your keyring, if it dosent work remove the 'unwanted' ssh key from ~/.ssh/config.



source



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






share|improve this answer




















  • 4





    This is the only answer that explains why it was persistently using the wrong github account despite my user.email being set correctly. Wish I could upvote five times.

    – Chris
    Nov 28 '17 at 6:29






  • 1





    in my case removing ssh key worked like a charm ssh-add -D

    – rPawel
    Jan 3 '18 at 16:15











  • This was the only answer that worked for me. Thanks!!

    – Edward Hartnett
    May 23 '18 at 13:54











  • The only option that worked. It doesn't make sense why git would not pick the right key. Since we are mentioning the ssh file it has to use in config.

    – Revanth Kumar
    May 24 '18 at 18:51











  • When I do ssh-add -l I get an answer that doesn't help. It types out 4096 SHA256:lotsOfGibberish,about40chars (RSA) I don't know how to us this information.

    – MiguelMunoz
    Nov 17 '18 at 5:42


















15














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






share|improve this answer























  • @VonC, despite your answer was great, it didn't work at all. This is the only solution that worked for me. I wonder if it's git issue or OSX...

    – swilgosz
    Mar 25 '16 at 7:05






  • 32





    git config --system --unset credential.helper worked for me, I'm now asked for my GitHub credentials on push again and can supply the correct user ID and password.

    – CoDEmanX
    Sep 2 '16 at 12:44











  • @CoDEmanX your's was the only answer which worked for me. For anyone else who comes across this, it was because we use 2FA at work with github and I needed to generate a token from the github gui first and use that as my password from the command line after I had reset my local credentials ! check out https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/ for details

    – vancouverwill
    May 9 '18 at 9:14











  • Its just the .gitconfig file . Either remove that or reset it... I faced this problem when I submitted a trial project for an interview. Damn it hurts though. Its with the config file

    – Girish
    Jul 22 '18 at 18:23


















11















it looks like my terminal does the commits with my username, but pushes them with the other one




Author and committer name and email (which are important for GitHub) are derived from:



git config user.name
git config user.email


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



GIT_AUTHOR_NAME
GIT_AUTHOR_EMAIL
GIT_COMMITTER_NAME
GIT_COMMITTER_EMAIL


So double-check those variables.




Things work back normally if I force the user in the .git/config of a repository but I don't think that's the good option.




But it should be a good solution.

When using an https url, I always specify the user in it to make sure the authentication is done with the right user.



http://USER@github.com/USER/REPO.git





share|improve this answer

























  • Thanks for your reply VonC ! Unfortunately, my git configcredentials are right and there's no environnement variables set in my /username/.bashrc file...

    – Yinfei
    Feb 7 '14 at 9:36











  • @Yinfei84 nonetheless, check your 'env' output.

    – VonC
    Feb 7 '14 at 9:41











  • No sign of those variables there too...

    – Yinfei
    Feb 7 '14 at 9:47











  • @Yinfei84 what would happen if (to test it out) you set those variables explicitly, and try a commit and a push. Would that work better then?

    – VonC
    Feb 7 '14 at 10:43






  • 2





    Excuse me if I wast clear, I meant that it worked if I force the user on the path like : http://USER@github.com/USER/REPO.git

    – Yinfei
    Feb 7 '14 at 11:41


















7














If you are using MAC, then go to Keychain Access and remove the entry of the user for which you don't want git access.






share|improve this answer






























    7














    A temporary solution is first run killall ssh-agent then add the ssh keys generated for the account you need to use ssh-add ~/.ssh/id_4shameer



    It will help us to work on multiple github account when we will get the error of type ERROR: Permission to user/repo-git.git denied to username.






    share|improve this answer























    • I did that after having removed any Github entry from MacOS keychain, and it worked perfectly. Two points, after the killall, the ssh-agent has to be restarted with eval "$(ssh-agent -s)", and the ssh-addcommand has to be executed with sudo.

      – arvymetal
      Jul 25 '17 at 15:42



















    3














    The solution for me was to add an entry in 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 'git push' using ssh, your computer grabs id_rsa by default and uses that as its ssh identity.

    3. github can't (unsurprisingly) deconflict which account you mean, since it's basing the account off the key it is presented, which if tied to more than one account, leads to pain like this. The killer is, for a long time, I was getting away with this and things just worked out.

    The entry I added is:



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


    I had created a new key, unique to my account, as id_rsa_waterproofpatch. This entry in my ssh config specifies that for connections to github.com, I wish to present this key.



    Another solution would probably have been for me to log into the other account, delete the duplicate ssh key.






    share|improve this answer
































      3














      I'm using Windows 10 and I faced the same issue today. In my case my credentials for different user were saved by Windows Credential manager. Thus deleting/unsetting git credentials with below command,
      git config --global --unset credential.helper



      didn't help. I had to manually delete the entry in Windows by following the below way,



      Start --> Control Panel ---> User Accounts ---> Manager your credentials ---> Windows Credentials



      Then search for an entry like, git:https://github.com and remove it. It works fine after that.






      share|improve this answer






























        0














        clearing keychain didn't help... I had to ssh-add -D and re-add the key with ssh-add <keyfile>






        share|improve this answer






























          0














          I solved this problem removing (or renaming to *.bak) the id_rsa and id_rsa.pub file on MacOS High Sierra. Idea from here.



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






          share|improve this answer






























            0














            That's what worked for me:



            1. Changing the credentials inside .git-credentials

            2. Changing the global user.name and user.email inside .gitconfig





            share|improve this answer
































              0














              What worked for me removing the repo and adding it again:



              git remote rm origin
              git remote add origin git@github.com:fguillen/MyApp.git





              share|improve this answer






























                0














                I have the same problem in windows10 even after uninstall my git, as @user542833 says it is because windows cache and you should remove Github credentials in your windows Credential Manager and when you again attempting to push, windows ask your credential and set it again






                share|improve this answer























                  Your Answer






                  StackExchange.ifUsing("editor", function ()
                  StackExchange.using("externalEditor", function ()
                  StackExchange.using("snippets", function ()
                  StackExchange.snippets.init();
                  );
                  );
                  , "code-snippets");

                  StackExchange.ready(function()
                  var channelOptions =
                  tags: "".split(" "),
                  id: "1"
                  ;
                  initTagRenderer("".split(" "), "".split(" "), channelOptions);

                  StackExchange.using("externalEditor", function()
                  // Have to fire editor after snippets, if snippets enabled
                  if (StackExchange.settings.snippets.snippetsEnabled)
                  StackExchange.using("snippets", function()
                  createEditor();
                  );

                  else
                  createEditor();

                  );

                  function createEditor()
                  StackExchange.prepareEditor(
                  heartbeatType: 'answer',
                  autoActivateHeartbeat: false,
                  convertImagesToLinks: true,
                  noModals: true,
                  showLowRepImageUploadWarning: true,
                  reputationToPostImages: 10,
                  bindNavPrevention: true,
                  postfix: "",
                  imageUploader:
                  brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                  contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                  allowUrls: true
                  ,
                  onDemand: true,
                  discardSelector: ".discard-answer"
                  ,immediatelyShowMarkdownHelp:true
                  );



                  );













                  draft saved

                  draft discarded


















                  StackExchange.ready(
                  function ()
                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f21615431%2fgit-pushes-with-wrong-user-from-terminal%23new-answer', 'question_page');

                  );

                  Post as a guest















                  Required, but never shown

























                  13 Answers
                  13






                  active

                  oldest

                  votes








                  13 Answers
                  13






                  active

                  oldest

                  votes









                  active

                  oldest

                  votes






                  active

                  oldest

                  votes









                  140














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



                  start keychain access (start spotlight via cmd + space, type keychain, press enter)



                  Under keychains on the upper left, select "login"
                  Under category on the left, select "passwords"



                  find the name "github" and delete it.






                  share|improve this answer


















                  • 2





                    Make sure you delete all github entry here & set the login configuration *git config --global user.name <name> *git config --global user.email <email>

                    – Shank_Transformer
                    Mar 9 '15 at 8:07












                  • In my case, SourceTree was experiencing this problem. Deleting the item in the keychain fixed it!

                    – Shoerob
                    May 1 '15 at 19:00






                  • 1





                    @Shank_Transformer your solution worked for me! Thank you!

                    – Nazariy1995
                    May 3 '16 at 19:22











                  • You may have to search for (or launch directly) seahorse on Ubuntu.

                    – caw
                    Jun 11 '17 at 23:13






                  • 3





                    I am in debt to you sir

                    – Baconbeastnz
                    Mar 5 '18 at 10:08















                  140














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



                  start keychain access (start spotlight via cmd + space, type keychain, press enter)



                  Under keychains on the upper left, select "login"
                  Under category on the left, select "passwords"



                  find the name "github" and delete it.






                  share|improve this answer


















                  • 2





                    Make sure you delete all github entry here & set the login configuration *git config --global user.name <name> *git config --global user.email <email>

                    – Shank_Transformer
                    Mar 9 '15 at 8:07












                  • In my case, SourceTree was experiencing this problem. Deleting the item in the keychain fixed it!

                    – Shoerob
                    May 1 '15 at 19:00






                  • 1





                    @Shank_Transformer your solution worked for me! Thank you!

                    – Nazariy1995
                    May 3 '16 at 19:22











                  • You may have to search for (or launch directly) seahorse on Ubuntu.

                    – caw
                    Jun 11 '17 at 23:13






                  • 3





                    I am in debt to you sir

                    – Baconbeastnz
                    Mar 5 '18 at 10:08













                  140












                  140








                  140







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



                  start keychain access (start spotlight via cmd + space, type keychain, press enter)



                  Under keychains on the upper left, select "login"
                  Under category on the left, select "passwords"



                  find the name "github" and delete it.






                  share|improve this answer













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



                  start keychain access (start spotlight via cmd + space, type keychain, press enter)



                  Under keychains on the upper left, select "login"
                  Under category on the left, select "passwords"



                  find the name "github" and delete it.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jun 10 '14 at 0:10









                  user542833user542833

                  7,4403126




                  7,4403126







                  • 2





                    Make sure you delete all github entry here & set the login configuration *git config --global user.name <name> *git config --global user.email <email>

                    – Shank_Transformer
                    Mar 9 '15 at 8:07












                  • In my case, SourceTree was experiencing this problem. Deleting the item in the keychain fixed it!

                    – Shoerob
                    May 1 '15 at 19:00






                  • 1





                    @Shank_Transformer your solution worked for me! Thank you!

                    – Nazariy1995
                    May 3 '16 at 19:22











                  • You may have to search for (or launch directly) seahorse on Ubuntu.

                    – caw
                    Jun 11 '17 at 23:13






                  • 3





                    I am in debt to you sir

                    – Baconbeastnz
                    Mar 5 '18 at 10:08












                  • 2





                    Make sure you delete all github entry here & set the login configuration *git config --global user.name <name> *git config --global user.email <email>

                    – Shank_Transformer
                    Mar 9 '15 at 8:07












                  • In my case, SourceTree was experiencing this problem. Deleting the item in the keychain fixed it!

                    – Shoerob
                    May 1 '15 at 19:00






                  • 1





                    @Shank_Transformer your solution worked for me! Thank you!

                    – Nazariy1995
                    May 3 '16 at 19:22











                  • You may have to search for (or launch directly) seahorse on Ubuntu.

                    – caw
                    Jun 11 '17 at 23:13






                  • 3





                    I am in debt to you sir

                    – Baconbeastnz
                    Mar 5 '18 at 10:08







                  2




                  2





                  Make sure you delete all github entry here & set the login configuration *git config --global user.name <name> *git config --global user.email <email>

                  – Shank_Transformer
                  Mar 9 '15 at 8:07






                  Make sure you delete all github entry here & set the login configuration *git config --global user.name <name> *git config --global user.email <email>

                  – Shank_Transformer
                  Mar 9 '15 at 8:07














                  In my case, SourceTree was experiencing this problem. Deleting the item in the keychain fixed it!

                  – Shoerob
                  May 1 '15 at 19:00





                  In my case, SourceTree was experiencing this problem. Deleting the item in the keychain fixed it!

                  – Shoerob
                  May 1 '15 at 19:00




                  1




                  1





                  @Shank_Transformer your solution worked for me! Thank you!

                  – Nazariy1995
                  May 3 '16 at 19:22





                  @Shank_Transformer your solution worked for me! Thank you!

                  – Nazariy1995
                  May 3 '16 at 19:22













                  You may have to search for (or launch directly) seahorse on Ubuntu.

                  – caw
                  Jun 11 '17 at 23:13





                  You may have to search for (or launch directly) seahorse on Ubuntu.

                  – caw
                  Jun 11 '17 at 23:13




                  3




                  3





                  I am in debt to you sir

                  – Baconbeastnz
                  Mar 5 '18 at 10:08





                  I am in debt to you sir

                  – Baconbeastnz
                  Mar 5 '18 at 10:08













                  23














                  github identifies you by the ssh key it sees, not by any setting from git.



                  Therefore, you need to ensure that your work account's ssh key is not in your keyring when you try to push from your personal account and vice versa.



                  Use ssh-add -l to determine which keys are in your keyring, and ssh-add -d <keyfile> to remove a key from your keyring, if it dosent work remove the 'unwanted' ssh key from ~/.ssh/config.



                  source



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






                  share|improve this answer




















                  • 4





                    This is the only answer that explains why it was persistently using the wrong github account despite my user.email being set correctly. Wish I could upvote five times.

                    – Chris
                    Nov 28 '17 at 6:29






                  • 1





                    in my case removing ssh key worked like a charm ssh-add -D

                    – rPawel
                    Jan 3 '18 at 16:15











                  • This was the only answer that worked for me. Thanks!!

                    – Edward Hartnett
                    May 23 '18 at 13:54











                  • The only option that worked. It doesn't make sense why git would not pick the right key. Since we are mentioning the ssh file it has to use in config.

                    – Revanth Kumar
                    May 24 '18 at 18:51











                  • When I do ssh-add -l I get an answer that doesn't help. It types out 4096 SHA256:lotsOfGibberish,about40chars (RSA) I don't know how to us this information.

                    – MiguelMunoz
                    Nov 17 '18 at 5:42















                  23














                  github identifies you by the ssh key it sees, not by any setting from git.



                  Therefore, you need to ensure that your work account's ssh key is not in your keyring when you try to push from your personal account and vice versa.



                  Use ssh-add -l to determine which keys are in your keyring, and ssh-add -d <keyfile> to remove a key from your keyring, if it dosent work remove the 'unwanted' ssh key from ~/.ssh/config.



                  source



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






                  share|improve this answer




















                  • 4





                    This is the only answer that explains why it was persistently using the wrong github account despite my user.email being set correctly. Wish I could upvote five times.

                    – Chris
                    Nov 28 '17 at 6:29






                  • 1





                    in my case removing ssh key worked like a charm ssh-add -D

                    – rPawel
                    Jan 3 '18 at 16:15











                  • This was the only answer that worked for me. Thanks!!

                    – Edward Hartnett
                    May 23 '18 at 13:54











                  • The only option that worked. It doesn't make sense why git would not pick the right key. Since we are mentioning the ssh file it has to use in config.

                    – Revanth Kumar
                    May 24 '18 at 18:51











                  • When I do ssh-add -l I get an answer that doesn't help. It types out 4096 SHA256:lotsOfGibberish,about40chars (RSA) I don't know how to us this information.

                    – MiguelMunoz
                    Nov 17 '18 at 5:42













                  23












                  23








                  23







                  github identifies you by the ssh key it sees, not by any setting from git.



                  Therefore, you need to ensure that your work account's ssh key is not in your keyring when you try to push from your personal account and vice versa.



                  Use ssh-add -l to determine which keys are in your keyring, and ssh-add -d <keyfile> to remove a key from your keyring, if it dosent work remove the 'unwanted' ssh key from ~/.ssh/config.



                  source



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






                  share|improve this answer















                  github identifies you by the ssh key it sees, not by any setting from git.



                  Therefore, you need to ensure that your work account's ssh key is not in your keyring when you try to push from your personal account and vice versa.



                  Use ssh-add -l to determine which keys are in your keyring, and ssh-add -d <keyfile> to remove a key from your keyring, if it dosent work remove the 'unwanted' ssh key from ~/.ssh/config.



                  source



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







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Mar 23 at 8:23

























                  answered Sep 11 '16 at 22:34









                  nithinnithin

                  1,517821




                  1,517821







                  • 4





                    This is the only answer that explains why it was persistently using the wrong github account despite my user.email being set correctly. Wish I could upvote five times.

                    – Chris
                    Nov 28 '17 at 6:29






                  • 1





                    in my case removing ssh key worked like a charm ssh-add -D

                    – rPawel
                    Jan 3 '18 at 16:15











                  • This was the only answer that worked for me. Thanks!!

                    – Edward Hartnett
                    May 23 '18 at 13:54











                  • The only option that worked. It doesn't make sense why git would not pick the right key. Since we are mentioning the ssh file it has to use in config.

                    – Revanth Kumar
                    May 24 '18 at 18:51











                  • When I do ssh-add -l I get an answer that doesn't help. It types out 4096 SHA256:lotsOfGibberish,about40chars (RSA) I don't know how to us this information.

                    – MiguelMunoz
                    Nov 17 '18 at 5:42












                  • 4





                    This is the only answer that explains why it was persistently using the wrong github account despite my user.email being set correctly. Wish I could upvote five times.

                    – Chris
                    Nov 28 '17 at 6:29






                  • 1





                    in my case removing ssh key worked like a charm ssh-add -D

                    – rPawel
                    Jan 3 '18 at 16:15











                  • This was the only answer that worked for me. Thanks!!

                    – Edward Hartnett
                    May 23 '18 at 13:54











                  • The only option that worked. It doesn't make sense why git would not pick the right key. Since we are mentioning the ssh file it has to use in config.

                    – Revanth Kumar
                    May 24 '18 at 18:51











                  • When I do ssh-add -l I get an answer that doesn't help. It types out 4096 SHA256:lotsOfGibberish,about40chars (RSA) I don't know how to us this information.

                    – MiguelMunoz
                    Nov 17 '18 at 5:42







                  4




                  4





                  This is the only answer that explains why it was persistently using the wrong github account despite my user.email being set correctly. Wish I could upvote five times.

                  – Chris
                  Nov 28 '17 at 6:29





                  This is the only answer that explains why it was persistently using the wrong github account despite my user.email being set correctly. Wish I could upvote five times.

                  – Chris
                  Nov 28 '17 at 6:29




                  1




                  1





                  in my case removing ssh key worked like a charm ssh-add -D

                  – rPawel
                  Jan 3 '18 at 16:15





                  in my case removing ssh key worked like a charm ssh-add -D

                  – rPawel
                  Jan 3 '18 at 16:15













                  This was the only answer that worked for me. Thanks!!

                  – Edward Hartnett
                  May 23 '18 at 13:54





                  This was the only answer that worked for me. Thanks!!

                  – Edward Hartnett
                  May 23 '18 at 13:54













                  The only option that worked. It doesn't make sense why git would not pick the right key. Since we are mentioning the ssh file it has to use in config.

                  – Revanth Kumar
                  May 24 '18 at 18:51





                  The only option that worked. It doesn't make sense why git would not pick the right key. Since we are mentioning the ssh file it has to use in config.

                  – Revanth Kumar
                  May 24 '18 at 18:51













                  When I do ssh-add -l I get an answer that doesn't help. It types out 4096 SHA256:lotsOfGibberish,about40chars (RSA) I don't know how to us this information.

                  – MiguelMunoz
                  Nov 17 '18 at 5:42





                  When I do ssh-add -l I get an answer that doesn't help. It types out 4096 SHA256:lotsOfGibberish,about40chars (RSA) I don't know how to us this information.

                  – MiguelMunoz
                  Nov 17 '18 at 5:42











                  15














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






                  share|improve this answer























                  • @VonC, despite your answer was great, it didn't work at all. This is the only solution that worked for me. I wonder if it's git issue or OSX...

                    – swilgosz
                    Mar 25 '16 at 7:05






                  • 32





                    git config --system --unset credential.helper worked for me, I'm now asked for my GitHub credentials on push again and can supply the correct user ID and password.

                    – CoDEmanX
                    Sep 2 '16 at 12:44











                  • @CoDEmanX your's was the only answer which worked for me. For anyone else who comes across this, it was because we use 2FA at work with github and I needed to generate a token from the github gui first and use that as my password from the command line after I had reset my local credentials ! check out https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/ for details

                    – vancouverwill
                    May 9 '18 at 9:14











                  • Its just the .gitconfig file . Either remove that or reset it... I faced this problem when I submitted a trial project for an interview. Damn it hurts though. Its with the config file

                    – Girish
                    Jul 22 '18 at 18:23















                  15














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






                  share|improve this answer























                  • @VonC, despite your answer was great, it didn't work at all. This is the only solution that worked for me. I wonder if it's git issue or OSX...

                    – swilgosz
                    Mar 25 '16 at 7:05






                  • 32





                    git config --system --unset credential.helper worked for me, I'm now asked for my GitHub credentials on push again and can supply the correct user ID and password.

                    – CoDEmanX
                    Sep 2 '16 at 12:44











                  • @CoDEmanX your's was the only answer which worked for me. For anyone else who comes across this, it was because we use 2FA at work with github and I needed to generate a token from the github gui first and use that as my password from the command line after I had reset my local credentials ! check out https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/ for details

                    – vancouverwill
                    May 9 '18 at 9:14











                  • Its just the .gitconfig file . Either remove that or reset it... I faced this problem when I submitted a trial project for an interview. Damn it hurts though. Its with the config file

                    – Girish
                    Jul 22 '18 at 18:23













                  15












                  15








                  15







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






                  share|improve this answer













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







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 12 '14 at 8:35









                  YinfeiYinfei

                  6111613




                  6111613












                  • @VonC, despite your answer was great, it didn't work at all. This is the only solution that worked for me. I wonder if it's git issue or OSX...

                    – swilgosz
                    Mar 25 '16 at 7:05






                  • 32





                    git config --system --unset credential.helper worked for me, I'm now asked for my GitHub credentials on push again and can supply the correct user ID and password.

                    – CoDEmanX
                    Sep 2 '16 at 12:44











                  • @CoDEmanX your's was the only answer which worked for me. For anyone else who comes across this, it was because we use 2FA at work with github and I needed to generate a token from the github gui first and use that as my password from the command line after I had reset my local credentials ! check out https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/ for details

                    – vancouverwill
                    May 9 '18 at 9:14











                  • Its just the .gitconfig file . Either remove that or reset it... I faced this problem when I submitted a trial project for an interview. Damn it hurts though. Its with the config file

                    – Girish
                    Jul 22 '18 at 18:23

















                  • @VonC, despite your answer was great, it didn't work at all. This is the only solution that worked for me. I wonder if it's git issue or OSX...

                    – swilgosz
                    Mar 25 '16 at 7:05






                  • 32





                    git config --system --unset credential.helper worked for me, I'm now asked for my GitHub credentials on push again and can supply the correct user ID and password.

                    – CoDEmanX
                    Sep 2 '16 at 12:44











                  • @CoDEmanX your's was the only answer which worked for me. For anyone else who comes across this, it was because we use 2FA at work with github and I needed to generate a token from the github gui first and use that as my password from the command line after I had reset my local credentials ! check out https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/ for details

                    – vancouverwill
                    May 9 '18 at 9:14











                  • Its just the .gitconfig file . Either remove that or reset it... I faced this problem when I submitted a trial project for an interview. Damn it hurts though. Its with the config file

                    – Girish
                    Jul 22 '18 at 18:23
















                  @VonC, despite your answer was great, it didn't work at all. This is the only solution that worked for me. I wonder if it's git issue or OSX...

                  – swilgosz
                  Mar 25 '16 at 7:05





                  @VonC, despite your answer was great, it didn't work at all. This is the only solution that worked for me. I wonder if it's git issue or OSX...

                  – swilgosz
                  Mar 25 '16 at 7:05




                  32




                  32





                  git config --system --unset credential.helper worked for me, I'm now asked for my GitHub credentials on push again and can supply the correct user ID and password.

                  – CoDEmanX
                  Sep 2 '16 at 12:44





                  git config --system --unset credential.helper worked for me, I'm now asked for my GitHub credentials on push again and can supply the correct user ID and password.

                  – CoDEmanX
                  Sep 2 '16 at 12:44













                  @CoDEmanX your's was the only answer which worked for me. For anyone else who comes across this, it was because we use 2FA at work with github and I needed to generate a token from the github gui first and use that as my password from the command line after I had reset my local credentials ! check out https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/ for details

                  – vancouverwill
                  May 9 '18 at 9:14





                  @CoDEmanX your's was the only answer which worked for me. For anyone else who comes across this, it was because we use 2FA at work with github and I needed to generate a token from the github gui first and use that as my password from the command line after I had reset my local credentials ! check out https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/ for details

                  – vancouverwill
                  May 9 '18 at 9:14













                  Its just the .gitconfig file . Either remove that or reset it... I faced this problem when I submitted a trial project for an interview. Damn it hurts though. Its with the config file

                  – Girish
                  Jul 22 '18 at 18:23





                  Its just the .gitconfig file . Either remove that or reset it... I faced this problem when I submitted a trial project for an interview. Damn it hurts though. Its with the config file

                  – Girish
                  Jul 22 '18 at 18:23











                  11















                  it looks like my terminal does the commits with my username, but pushes them with the other one




                  Author and committer name and email (which are important for GitHub) are derived from:



                  git config user.name
                  git config user.email


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



                  GIT_AUTHOR_NAME
                  GIT_AUTHOR_EMAIL
                  GIT_COMMITTER_NAME
                  GIT_COMMITTER_EMAIL


                  So double-check those variables.




                  Things work back normally if I force the user in the .git/config of a repository but I don't think that's the good option.




                  But it should be a good solution.

                  When using an https url, I always specify the user in it to make sure the authentication is done with the right user.



                  http://USER@github.com/USER/REPO.git





                  share|improve this answer

























                  • Thanks for your reply VonC ! Unfortunately, my git configcredentials are right and there's no environnement variables set in my /username/.bashrc file...

                    – Yinfei
                    Feb 7 '14 at 9:36











                  • @Yinfei84 nonetheless, check your 'env' output.

                    – VonC
                    Feb 7 '14 at 9:41











                  • No sign of those variables there too...

                    – Yinfei
                    Feb 7 '14 at 9:47











                  • @Yinfei84 what would happen if (to test it out) you set those variables explicitly, and try a commit and a push. Would that work better then?

                    – VonC
                    Feb 7 '14 at 10:43






                  • 2





                    Excuse me if I wast clear, I meant that it worked if I force the user on the path like : http://USER@github.com/USER/REPO.git

                    – Yinfei
                    Feb 7 '14 at 11:41















                  11















                  it looks like my terminal does the commits with my username, but pushes them with the other one




                  Author and committer name and email (which are important for GitHub) are derived from:



                  git config user.name
                  git config user.email


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



                  GIT_AUTHOR_NAME
                  GIT_AUTHOR_EMAIL
                  GIT_COMMITTER_NAME
                  GIT_COMMITTER_EMAIL


                  So double-check those variables.




                  Things work back normally if I force the user in the .git/config of a repository but I don't think that's the good option.




                  But it should be a good solution.

                  When using an https url, I always specify the user in it to make sure the authentication is done with the right user.



                  http://USER@github.com/USER/REPO.git





                  share|improve this answer

























                  • Thanks for your reply VonC ! Unfortunately, my git configcredentials are right and there's no environnement variables set in my /username/.bashrc file...

                    – Yinfei
                    Feb 7 '14 at 9:36











                  • @Yinfei84 nonetheless, check your 'env' output.

                    – VonC
                    Feb 7 '14 at 9:41











                  • No sign of those variables there too...

                    – Yinfei
                    Feb 7 '14 at 9:47











                  • @Yinfei84 what would happen if (to test it out) you set those variables explicitly, and try a commit and a push. Would that work better then?

                    – VonC
                    Feb 7 '14 at 10:43






                  • 2





                    Excuse me if I wast clear, I meant that it worked if I force the user on the path like : http://USER@github.com/USER/REPO.git

                    – Yinfei
                    Feb 7 '14 at 11:41













                  11












                  11








                  11








                  it looks like my terminal does the commits with my username, but pushes them with the other one




                  Author and committer name and email (which are important for GitHub) are derived from:



                  git config user.name
                  git config user.email


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



                  GIT_AUTHOR_NAME
                  GIT_AUTHOR_EMAIL
                  GIT_COMMITTER_NAME
                  GIT_COMMITTER_EMAIL


                  So double-check those variables.




                  Things work back normally if I force the user in the .git/config of a repository but I don't think that's the good option.




                  But it should be a good solution.

                  When using an https url, I always specify the user in it to make sure the authentication is done with the right user.



                  http://USER@github.com/USER/REPO.git





                  share|improve this answer
















                  it looks like my terminal does the commits with my username, but pushes them with the other one




                  Author and committer name and email (which are important for GitHub) are derived from:



                  git config user.name
                  git config user.email


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



                  GIT_AUTHOR_NAME
                  GIT_AUTHOR_EMAIL
                  GIT_COMMITTER_NAME
                  GIT_COMMITTER_EMAIL


                  So double-check those variables.




                  Things work back normally if I force the user in the .git/config of a repository but I don't think that's the good option.




                  But it should be a good solution.

                  When using an https url, I always specify the user in it to make sure the authentication is done with the right user.



                  http://USER@github.com/USER/REPO.git






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Feb 7 '14 at 11:44

























                  answered Feb 7 '14 at 7:35









                  VonCVonC

                  860k30927543321




                  860k30927543321












                  • Thanks for your reply VonC ! Unfortunately, my git configcredentials are right and there's no environnement variables set in my /username/.bashrc file...

                    – Yinfei
                    Feb 7 '14 at 9:36











                  • @Yinfei84 nonetheless, check your 'env' output.

                    – VonC
                    Feb 7 '14 at 9:41











                  • No sign of those variables there too...

                    – Yinfei
                    Feb 7 '14 at 9:47











                  • @Yinfei84 what would happen if (to test it out) you set those variables explicitly, and try a commit and a push. Would that work better then?

                    – VonC
                    Feb 7 '14 at 10:43






                  • 2





                    Excuse me if I wast clear, I meant that it worked if I force the user on the path like : http://USER@github.com/USER/REPO.git

                    – Yinfei
                    Feb 7 '14 at 11:41

















                  • Thanks for your reply VonC ! Unfortunately, my git configcredentials are right and there's no environnement variables set in my /username/.bashrc file...

                    – Yinfei
                    Feb 7 '14 at 9:36











                  • @Yinfei84 nonetheless, check your 'env' output.

                    – VonC
                    Feb 7 '14 at 9:41











                  • No sign of those variables there too...

                    – Yinfei
                    Feb 7 '14 at 9:47











                  • @Yinfei84 what would happen if (to test it out) you set those variables explicitly, and try a commit and a push. Would that work better then?

                    – VonC
                    Feb 7 '14 at 10:43






                  • 2





                    Excuse me if I wast clear, I meant that it worked if I force the user on the path like : http://USER@github.com/USER/REPO.git

                    – Yinfei
                    Feb 7 '14 at 11:41
















                  Thanks for your reply VonC ! Unfortunately, my git configcredentials are right and there's no environnement variables set in my /username/.bashrc file...

                  – Yinfei
                  Feb 7 '14 at 9:36





                  Thanks for your reply VonC ! Unfortunately, my git configcredentials are right and there's no environnement variables set in my /username/.bashrc file...

                  – Yinfei
                  Feb 7 '14 at 9:36













                  @Yinfei84 nonetheless, check your 'env' output.

                  – VonC
                  Feb 7 '14 at 9:41





                  @Yinfei84 nonetheless, check your 'env' output.

                  – VonC
                  Feb 7 '14 at 9:41













                  No sign of those variables there too...

                  – Yinfei
                  Feb 7 '14 at 9:47





                  No sign of those variables there too...

                  – Yinfei
                  Feb 7 '14 at 9:47













                  @Yinfei84 what would happen if (to test it out) you set those variables explicitly, and try a commit and a push. Would that work better then?

                  – VonC
                  Feb 7 '14 at 10:43





                  @Yinfei84 what would happen if (to test it out) you set those variables explicitly, and try a commit and a push. Would that work better then?

                  – VonC
                  Feb 7 '14 at 10:43




                  2




                  2





                  Excuse me if I wast clear, I meant that it worked if I force the user on the path like : http://USER@github.com/USER/REPO.git

                  – Yinfei
                  Feb 7 '14 at 11:41





                  Excuse me if I wast clear, I meant that it worked if I force the user on the path like : http://USER@github.com/USER/REPO.git

                  – Yinfei
                  Feb 7 '14 at 11:41











                  7














                  If you are using MAC, then go to Keychain Access and remove the entry of the user for which you don't want git access.






                  share|improve this answer



























                    7














                    If you are using MAC, then go to Keychain Access and remove the entry of the user for which you don't want git access.






                    share|improve this answer

























                      7












                      7








                      7







                      If you are using MAC, then go to Keychain Access and remove the entry of the user for which you don't want git access.






                      share|improve this answer













                      If you are using MAC, then go to Keychain Access and remove the entry of the user for which you don't want git access.







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered May 15 '16 at 4:04









                      Chitrapal SinghChitrapal Singh

                      6911




                      6911





















                          7














                          A temporary solution is first run killall ssh-agent then add the ssh keys generated for the account you need to use ssh-add ~/.ssh/id_4shameer



                          It will help us to work on multiple github account when we will get the error of type ERROR: Permission to user/repo-git.git denied to username.






                          share|improve this answer























                          • I did that after having removed any Github entry from MacOS keychain, and it worked perfectly. Two points, after the killall, the ssh-agent has to be restarted with eval "$(ssh-agent -s)", and the ssh-addcommand has to be executed with sudo.

                            – arvymetal
                            Jul 25 '17 at 15:42
















                          7














                          A temporary solution is first run killall ssh-agent then add the ssh keys generated for the account you need to use ssh-add ~/.ssh/id_4shameer



                          It will help us to work on multiple github account when we will get the error of type ERROR: Permission to user/repo-git.git denied to username.






                          share|improve this answer























                          • I did that after having removed any Github entry from MacOS keychain, and it worked perfectly. Two points, after the killall, the ssh-agent has to be restarted with eval "$(ssh-agent -s)", and the ssh-addcommand has to be executed with sudo.

                            – arvymetal
                            Jul 25 '17 at 15:42














                          7












                          7








                          7







                          A temporary solution is first run killall ssh-agent then add the ssh keys generated for the account you need to use ssh-add ~/.ssh/id_4shameer



                          It will help us to work on multiple github account when we will get the error of type ERROR: Permission to user/repo-git.git denied to username.






                          share|improve this answer













                          A temporary solution is first run killall ssh-agent then add the ssh keys generated for the account you need to use ssh-add ~/.ssh/id_4shameer



                          It will help us to work on multiple github account when we will get the error of type ERROR: Permission to user/repo-git.git denied to username.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Nov 2 '16 at 8:44









                          mshameermshameer

                          396412




                          396412












                          • I did that after having removed any Github entry from MacOS keychain, and it worked perfectly. Two points, after the killall, the ssh-agent has to be restarted with eval "$(ssh-agent -s)", and the ssh-addcommand has to be executed with sudo.

                            – arvymetal
                            Jul 25 '17 at 15:42


















                          • I did that after having removed any Github entry from MacOS keychain, and it worked perfectly. Two points, after the killall, the ssh-agent has to be restarted with eval "$(ssh-agent -s)", and the ssh-addcommand has to be executed with sudo.

                            – arvymetal
                            Jul 25 '17 at 15:42

















                          I did that after having removed any Github entry from MacOS keychain, and it worked perfectly. Two points, after the killall, the ssh-agent has to be restarted with eval "$(ssh-agent -s)", and the ssh-addcommand has to be executed with sudo.

                          – arvymetal
                          Jul 25 '17 at 15:42






                          I did that after having removed any Github entry from MacOS keychain, and it worked perfectly. Two points, after the killall, the ssh-agent has to be restarted with eval "$(ssh-agent -s)", and the ssh-addcommand has to be executed with sudo.

                          – arvymetal
                          Jul 25 '17 at 15:42












                          3














                          The solution for me was to add an entry in 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 'git push' using ssh, your computer grabs id_rsa by default and uses that as its ssh identity.

                          3. github can't (unsurprisingly) deconflict which account you mean, since it's basing the account off the key it is presented, which if tied to more than one account, leads to pain like this. The killer is, for a long time, I was getting away with this and things just worked out.

                          The entry I added is:



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


                          I had created a new key, unique to my account, as id_rsa_waterproofpatch. This entry in my ssh config specifies that for connections to github.com, I wish to present this key.



                          Another solution would probably have been for me to log into the other account, delete the duplicate ssh key.






                          share|improve this answer





























                            3














                            The solution for me was to add an entry in 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 'git push' using ssh, your computer grabs id_rsa by default and uses that as its ssh identity.

                            3. github can't (unsurprisingly) deconflict which account you mean, since it's basing the account off the key it is presented, which if tied to more than one account, leads to pain like this. The killer is, for a long time, I was getting away with this and things just worked out.

                            The entry I added is:



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


                            I had created a new key, unique to my account, as id_rsa_waterproofpatch. This entry in my ssh config specifies that for connections to github.com, I wish to present this key.



                            Another solution would probably have been for me to log into the other account, delete the duplicate ssh key.






                            share|improve this answer



























                              3












                              3








                              3







                              The solution for me was to add an entry in 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 'git push' using ssh, your computer grabs id_rsa by default and uses that as its ssh identity.

                              3. github can't (unsurprisingly) deconflict which account you mean, since it's basing the account off the key it is presented, which if tied to more than one account, leads to pain like this. The killer is, for a long time, I was getting away with this and things just worked out.

                              The entry I added is:



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


                              I had created a new key, unique to my account, as id_rsa_waterproofpatch. This entry in my ssh config specifies that for connections to github.com, I wish to present this key.



                              Another solution would probably have been for me to log into the other account, delete the duplicate ssh key.






                              share|improve this answer















                              The solution for me was to add an entry in 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 'git push' using ssh, your computer grabs id_rsa by default and uses that as its ssh identity.

                              3. github can't (unsurprisingly) deconflict which account you mean, since it's basing the account off the key it is presented, which if tied to more than one account, leads to pain like this. The killer is, for a long time, I was getting away with this and things just worked out.

                              The entry I added is:



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


                              I had created a new key, unique to my account, as id_rsa_waterproofpatch. This entry in my ssh config specifies that for connections to github.com, I wish to present this key.



                              Another solution would probably have been for me to log into the other account, delete the duplicate ssh key.







                              share|improve this answer














                              share|improve this answer



                              share|improve this answer








                              edited May 3 '18 at 3:48

























                              answered May 2 '18 at 4:22









                              waterproofpatchwaterproofpatch

                              614




                              614





















                                  3














                                  I'm using Windows 10 and I faced the same issue today. In my case my credentials for different user were saved by Windows Credential manager. Thus deleting/unsetting git credentials with below command,
                                  git config --global --unset credential.helper



                                  didn't help. I had to manually delete the entry in Windows by following the below way,



                                  Start --> Control Panel ---> User Accounts ---> Manager your credentials ---> Windows Credentials



                                  Then search for an entry like, git:https://github.com and remove it. It works fine after that.






                                  share|improve this answer



























                                    3














                                    I'm using Windows 10 and I faced the same issue today. In my case my credentials for different user were saved by Windows Credential manager. Thus deleting/unsetting git credentials with below command,
                                    git config --global --unset credential.helper



                                    didn't help. I had to manually delete the entry in Windows by following the below way,



                                    Start --> Control Panel ---> User Accounts ---> Manager your credentials ---> Windows Credentials



                                    Then search for an entry like, git:https://github.com and remove it. It works fine after that.






                                    share|improve this answer

























                                      3












                                      3








                                      3







                                      I'm using Windows 10 and I faced the same issue today. In my case my credentials for different user were saved by Windows Credential manager. Thus deleting/unsetting git credentials with below command,
                                      git config --global --unset credential.helper



                                      didn't help. I had to manually delete the entry in Windows by following the below way,



                                      Start --> Control Panel ---> User Accounts ---> Manager your credentials ---> Windows Credentials



                                      Then search for an entry like, git:https://github.com and remove it. It works fine after that.






                                      share|improve this answer













                                      I'm using Windows 10 and I faced the same issue today. In my case my credentials for different user were saved by Windows Credential manager. Thus deleting/unsetting git credentials with below command,
                                      git config --global --unset credential.helper



                                      didn't help. I had to manually delete the entry in Windows by following the below way,



                                      Start --> Control Panel ---> User Accounts ---> Manager your credentials ---> Windows Credentials



                                      Then search for an entry like, git:https://github.com and remove it. It works fine after that.







                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered Mar 2 at 13:21









                                      GowthamGowtham

                                      365




                                      365





















                                          0














                                          clearing keychain didn't help... I had to ssh-add -D and re-add the key with ssh-add <keyfile>






                                          share|improve this answer



























                                            0














                                            clearing keychain didn't help... I had to ssh-add -D and re-add the key with ssh-add <keyfile>






                                            share|improve this answer

























                                              0












                                              0








                                              0







                                              clearing keychain didn't help... I had to ssh-add -D and re-add the key with ssh-add <keyfile>






                                              share|improve this answer













                                              clearing keychain didn't help... I had to ssh-add -D and re-add the key with ssh-add <keyfile>







                                              share|improve this answer












                                              share|improve this answer



                                              share|improve this answer










                                              answered May 3 '18 at 15:39









                                              Victor PiousboxVictor Piousbox

                                              2,20732754




                                              2,20732754





















                                                  0














                                                  I solved this problem removing (or renaming to *.bak) the id_rsa and id_rsa.pub file on MacOS High Sierra. Idea from here.



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






                                                  share|improve this answer



























                                                    0














                                                    I solved this problem removing (or renaming to *.bak) the id_rsa and id_rsa.pub file on MacOS High Sierra. Idea from here.



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






                                                    share|improve this answer

























                                                      0












                                                      0








                                                      0







                                                      I solved this problem removing (or renaming to *.bak) the id_rsa and id_rsa.pub file on MacOS High Sierra. Idea from here.



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






                                                      share|improve this answer













                                                      I solved this problem removing (or renaming to *.bak) the id_rsa and id_rsa.pub file on MacOS High Sierra. Idea from here.



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







                                                      share|improve this answer












                                                      share|improve this answer



                                                      share|improve this answer










                                                      answered Jul 18 '18 at 12:19









                                                      CodingYourLifeCodingYourLife

                                                      1,39631733




                                                      1,39631733





















                                                          0














                                                          That's what worked for me:



                                                          1. Changing the credentials inside .git-credentials

                                                          2. Changing the global user.name and user.email inside .gitconfig





                                                          share|improve this answer





























                                                            0














                                                            That's what worked for me:



                                                            1. Changing the credentials inside .git-credentials

                                                            2. Changing the global user.name and user.email inside .gitconfig





                                                            share|improve this answer



























                                                              0












                                                              0








                                                              0







                                                              That's what worked for me:



                                                              1. Changing the credentials inside .git-credentials

                                                              2. Changing the global user.name and user.email inside .gitconfig





                                                              share|improve this answer















                                                              That's what worked for me:



                                                              1. Changing the credentials inside .git-credentials

                                                              2. Changing the global user.name and user.email inside .gitconfig






                                                              share|improve this answer














                                                              share|improve this answer



                                                              share|improve this answer








                                                              edited Sep 11 '18 at 9:03

























                                                              answered Sep 10 '18 at 15:32









                                                              reshetechreshetech

                                                              629510




                                                              629510





















                                                                  0














                                                                  What worked for me removing the repo and adding it again:



                                                                  git remote rm origin
                                                                  git remote add origin git@github.com:fguillen/MyApp.git





                                                                  share|improve this answer



























                                                                    0














                                                                    What worked for me removing the repo and adding it again:



                                                                    git remote rm origin
                                                                    git remote add origin git@github.com:fguillen/MyApp.git





                                                                    share|improve this answer

























                                                                      0












                                                                      0








                                                                      0







                                                                      What worked for me removing the repo and adding it again:



                                                                      git remote rm origin
                                                                      git remote add origin git@github.com:fguillen/MyApp.git





                                                                      share|improve this answer













                                                                      What worked for me removing the repo and adding it again:



                                                                      git remote rm origin
                                                                      git remote add origin git@github.com:fguillen/MyApp.git






                                                                      share|improve this answer












                                                                      share|improve this answer



                                                                      share|improve this answer










                                                                      answered Jan 26 at 14:36









                                                                      fguillenfguillen

                                                                      22.4k1388149




                                                                      22.4k1388149





















                                                                          0














                                                                          I have the same problem in windows10 even after uninstall my git, as @user542833 says it is because windows cache and you should remove Github credentials in your windows Credential Manager and when you again attempting to push, windows ask your credential and set it again






                                                                          share|improve this answer



























                                                                            0














                                                                            I have the same problem in windows10 even after uninstall my git, as @user542833 says it is because windows cache and you should remove Github credentials in your windows Credential Manager and when you again attempting to push, windows ask your credential and set it again






                                                                            share|improve this answer

























                                                                              0












                                                                              0








                                                                              0







                                                                              I have the same problem in windows10 even after uninstall my git, as @user542833 says it is because windows cache and you should remove Github credentials in your windows Credential Manager and when you again attempting to push, windows ask your credential and set it again






                                                                              share|improve this answer













                                                                              I have the same problem in windows10 even after uninstall my git, as @user542833 says it is because windows cache and you should remove Github credentials in your windows Credential Manager and when you again attempting to push, windows ask your credential and set it again







                                                                              share|improve this answer












                                                                              share|improve this answer



                                                                              share|improve this answer










                                                                              answered Mar 5 at 13:04









                                                                              ghazaleh javaherighazaleh javaheri

                                                                              342211




                                                                              342211



























                                                                                  draft saved

                                                                                  draft discarded
















































                                                                                  Thanks for contributing an answer to Stack Overflow!


                                                                                  • Please be sure to answer the question. Provide details and share your research!

                                                                                  But avoid


                                                                                  • Asking for help, clarification, or responding to other answers.

                                                                                  • Making statements based on opinion; back them up with references or personal experience.

                                                                                  To learn more, see our tips on writing great answers.




                                                                                  draft saved


                                                                                  draft discarded














                                                                                  StackExchange.ready(
                                                                                  function ()
                                                                                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f21615431%2fgit-pushes-with-wrong-user-from-terminal%23new-answer', 'question_page');

                                                                                  );

                                                                                  Post as a guest















                                                                                  Required, but never shown





















































                                                                                  Required, but never shown














                                                                                  Required, but never shown












                                                                                  Required, but never shown







                                                                                  Required, but never shown

































                                                                                  Required, but never shown














                                                                                  Required, but never shown












                                                                                  Required, but never shown







                                                                                  Required, but never shown







                                                                                  Popular posts from this blog

                                                                                  SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                                                                                  용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

                                                                                  155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해