git pushes with wrong user from terminal

前端 未结 22 1399
夕颜
夕颜 2020-12-07 07:51

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

相关标签:
22条回答
  • 2020-12-07 07:53

    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.

    0 讨论(0)
  • 2020-12-07 07:53

    What a pain in the butt!

    problem:

    1. create a repo on git hub
    2. clone to local machine
    3. can not push 403.

    turns for unknow reason git push was using the wrong user. I have a couple of different git hub user ids. I work for 2 different companies and also have a student id

    I am working on a mac. here is what I finally did

    1) remove the credential.helper

    • some how the credential helper got set to osxkeychain
    • when I started keychain, click on login, passwords and searched for github I found 3 entries. I have no idea how keychain could possible know which one to use

    a. you need to figure out where the credential.helper is configured

    git config --local credential.helper
    git config --global credential.helper
    git config --system credential.helper
    

    b. once find the correct fig file remove it as follows

    git config --global --unset credential.helper
    

    Now in my local repo I hacked the .git/config file

    I changed

        url = https://github.com/aedavids/lab3RotationProject.git
    

    to

        url = https://myGitHubUserId@github.com/aedavids/lab3RotationProject.git
    
    0 讨论(0)
  • 2020-12-07 07:53

    That's what worked for me:

    1. Changing the credentials inside .git-credentials
    2. Changing the global user.name and user.email inside .gitconfig
    0 讨论(0)
  • 2020-12-07 07:55

    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.

    0 讨论(0)
  • 2020-12-07 07:56

    First Go to this path in Windows
    Start --> Control Panel --> User Accounts --> Manager your credentials --> Windows Credentials

    And Remove the credential from git:https://github.com

    Then add your GitHub account username and password from which you want to push the code at the same place.

    To check whether git will push from the username that you added now enter the following command in git bash.

    git config user.name
    

    This will show you the username from which the git will push. If the username is correct then your problem is solved.

    For me this didn't solve the problem it was still showing my previous account username that I removed.

    Now enter the username and email Id of the account from which you want to push in the following command in git bash.

    git config --global user.name your_username
    git config --global user.email your_emaiid
    

    This will now change the user.
    Before pushing any code you can verify whether the user is changed or not by again using the following command.

    git config user.name
    
    0 讨论(0)
  • 2020-12-07 08:01

    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.

    0 讨论(0)
提交回复
热议问题