Search code examples
git-bash

How can I change the user on Git Bash?


enter image description here

I want to sign out an actual user so I can sign in with another user.

What I see in Git bash is:

MINGW64 ~/Documents/NetBeansProjects/ConstructorJava (master)
git push -u origin/master
remote: Permission to Fre1234/ConstructorJava.git denied to Fre123.  
Fatal: unable to access https://github.com/Fre1234/ConstructorJava.git/": The requested URL returned error: 403

Solution

  • Check what git remote -v returns: the account used to push to an http url is usually embedded into the remote url itself.

    https://[email protected]/...
    

    If that is the case, put an url which will force Git to ask for the account to use when pushing:

    git remote set-url origin https://github.com/<user>/<repo>
    

    Or one to use the Fre1234 account:

    git remote set-url origin https://[email protected]/<user>/<repo>
    

    Also check if you installed your Git For Windows with or without a credential helper as in this question.


    The OP Fre1234 adds in the comments:

    I finally found the solution.
    Go to: (Windows) Control Panel -> User Accounts -> Manage your credentials -> Windows Credentials

    Under Generic Credentials there are some credentials related to Github,
    Click on them and click "Remove".

    That is because the default installation for Git for Windows set a Git-Credential-Manager-for-Windows.
    See git config --global credential.helper output (it should be manager)