How to change my Git username in terminal?

后端 未结 13 1792
予麋鹿
予麋鹿 2020-12-07 07:17

I was pushing and pulling from git in Terminal then I changed my username on github.com. I went to push some changes and it couldn\'t push because it was still recognizing

相关标签:
13条回答
  • 2020-12-07 07:31

    Please update new user repository URL

     git remote set-url origin https://username@bitbucket.org/repository.git
    

    I tried using below commands, it's not working:

    git config user.email "email@example.com"
    git config user.name  "user"
    

    OR

    git config --global user.email "email@example.com"
    git config --global user.name "user"
    
    0 讨论(0)
  • 2020-12-07 07:32
    1. In your terminal, navigate to the repo you want to make the changes in.
    2. Execute git config --list to check current username & email in your local repo.
    3. Change username & email as desired. Make it a global change or specific to the local repo:
      git config [--global] user.name "Full Name"
      git config [--global] user.email "email@address.com"

      Per repo basis you could also edit .git/config manually instead.
    4. Done!

    When performing step 2 if you see credential.helper=manager you need to open the credential manager of your computer (Win or Mac) and update the credentials there

    Here is how it look on windows

    Troubleshooting? Learn more

    0 讨论(0)
  • 2020-12-07 07:33
    **Check by executing this** 
    git config --list
    **Change user email** 
    git config --global user.email "email@example.com"
    **Change user name**
    git config --global user.name "user"
    **Change user credential name** 
    git config --global credential.username "new_username"
    **After this a window popup asking password.
    Enter password and proceed.**
    
    0 讨论(0)
  • 2020-12-07 07:36

    There is a easy solution for that problem, the solution is removed the certificate the yours Keychain, the previous thing will cause that it asks again to the user and password.

    Steps:

    1. Open keychain access

    1. Search the certificate gitHub.com.

    2. Remove gitHub.com certificate.

    3. Execute any operation with git in your terminal. this again ask your username and password.

    For Windows Users find the key chain by following:

    Control Panel >> User Account >> Credential Manager >> Windows Credential >> Generic Credential

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

    I recommend you to do this by simply go to your .git folder, then open config file. In the file paste your user info:

    [user]
        name = Your-Name
        email = Your-email
    

    This should be it.

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

    If you have cloned your repo using url that contains your username, then you should also change remote.origin.url property because otherwise it keeps asking password for the old username.

    example:

    remote.origin.url=https://<old_uname>@<repo_url>
    

    should change to

    remote.origin.url=https://<new_uname>@<repo_url>
    
    0 讨论(0)
提交回复
热议问题