Search code examples
gitgithubrenameaccount

How to safely change github account name?


I would like to change my github account name, I found an option in GitHub account settings.

However, I am concerned about consequences and would like to know what is the best strategy of name change, considering that I have some projects of my own tied to this account.

So far, I came up with this plan:

  1. Change account name in GitHub settings
  2. For each project's local folder in '.git / config' file update remote "origin" url to the new one

Will this work? Should there be any further steps on a computer which holds project sources? What will be the effect of name change on those who cloned or forked my projects on GitHub?

Thank you!


Solution

  • 1.) You have to change all your projects remote addresses. You can see them via:

    git remote -v
    

    After that remove the old remote addres:

    git remote rm git@github.com:old_account/foo.git
    

    finally add your new remote address:

    git remote add origin git@github.com:new_account/foo.git
    

    2.) All your cloned repos will break. There is no URL-redirect or anything similar. You can change your local cloned repos, but others have to point to the new repo addres(like in Step 1)

    Note: Github forked repos works without any problem.