Search code examples
gitgithubgit-config

How to change my Git username in terminal?


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 my old username.. How do I change/update my username on git in terminal?


Solution

  • You probably need to update the remote URL since github puts your username in it. You can take a look at the original URL by typing

    git config --get remote.origin.url
    

    Or just go to the repository page on Github and get the new URL. Then use

    git remote set-url origin https://{new url with username replaced}
    

    to update the URL with your new username.