Remove credentials from Git

后端 未结 30 1671
不知归路
不知归路 2020-11-21 10:13

I\'m working with several repositories, but lately I was just working in our internal one and all was great.

Today I had to commit and push code into other one, but

相关标签:
30条回答
  • Using latest version of git for Windows on Windows 10 Professional and I had a similar issue whereby I have two different GitHub accounts and also a Bitbucket account so things got a bit confusing for VS2017, git extensions and git bash.

    I first checked how git was handling my credentials with this command (run git bash with elevated commands or you get errors):

    git config --list
    

    I found the entry Credential Manager so I clicked on the START button > typed Credential Manager to and left-clicked on the credential manager yellow safe icon which launched the app. I then clicked on the Windows Credentials tabs and found the entry for my current git account which happened to be Bit-bucket so I deleted this account.

    But this didn't do the trick so the next step was to unset the credentials and I did this from the repository directory on my laptop that contains the GitHub project I am trying to push to the remote. I typed the following command:

    git config --system --unset credential.helper
    

    Then I did a git push and I was prompted for a GitHub username which I entered (the correct one I needed) and then the associated password and everything got pushed correctly.

    I am not sure how much of an issue this is going forward most people probably work off the one repository but I have to work across several and using different providers so may encounter this issue again.

    0 讨论(0)
  • 2020-11-21 10:48

    In our case, clearing the password in the user's .git-credentials file worked for us.

    c:\users\[username]\.git-credentials
    
    0 讨论(0)
  • 2020-11-21 10:50

    I faced the same issue as the OP. It was taking my old Git credentials stored somewhere on the system and I wanted to use Git with my new credentials, so I ran the command

    $ git config --system --list
    

    It showed

    credential.helper=manager
    

    Whenever I performed git push it was taking my old username which I set long back, and I wanted to use new a GitHub account to push changes. I later found that my old GitHub account credentials was stored under Control PanelUser AccountsCredential ManagerManage Windows Credentials.

    I just removed these credentials and when I performed git push it asked me for my GitHub credentials, and it worked like a charm.

    0 讨论(0)
  • 2020-11-21 10:50

    In my case, Git is using Windows to store credentials.

    All you have to do is remove the stored credentials stored in your Windows account:

    0 讨论(0)
  • 2020-11-21 10:51
    git config --list
    

    will show credential.helper = manager (this is on a windows machine)

    To disable this cached username/password for your current local git folder, simply enter

    git config credential.helper ""
    

    This way, git will prompt for password every time, ignoring what's saved inside "manager".

    0 讨论(0)
  • 2020-11-21 10:51

    In Windows 2003 Server with "wincred"*, none of the other answers helped me. I had to use cmdkey.

    • cmdkey /list lists all stored credentials.
    • cmdkey /delete:Target deletes the credential with "Target" name.

    (* By "wincred" I mean git config --global credential.helper wincred)

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