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.

  • Will changing my Github username to SnakeCase break anything?
  • Bitbucket different keys and accounts
  • Github - I switched accounts and now I can't push because I have the wrong username
  • Github wrong username
  • PhpStorm. Two GitHub projects handled with different GitHub accounts
  • GitHub username change (with noreply as email for commits)
  • 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!

  • git commit --amend is dangerous
  • Rails why use capistrano when you have git post-receive hook?
  • GIT manages file by storing diff?
  • How should I organize source control for Android projects including libraries?
  • Why should I avoid creating gitignore and README on GitHub
  • How to synchronize configuration between git setups?
  • 3 Solutions collect form web for “How to safely change github account name?”

    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.

    GitHub has recently changed their username rename system, and now sets up redirects for you.

    From What happens when I change my username? on GitHub Help:

    On the GitHub side, everything will behave as if your new username had
    always been your name. All of your repositories will now belong to
    that new name and the old username will essentially no longer exist.
    This can take a few minutes to complete after you initiate the change.

    Links to your previous profile page, such as
    https://github.com/previoususername, return a 404 error. We cannot set
    up a redirect from the old username to the new one for references like
    @mentions.

    However, redirects are setup for all your repositories. Both web and
    git access to the old location continue to function, and redirect
    toward the new username.

    I left a script in my ~/bin called git-reremote with the following content:

     #!/bin/sh
    old=richoH
    new=richo
    git remote -v | grep $old | while read name url type; do
        newurl=`echo $url | sed -e "s/$old/$new/"`
        git remote set-url $name $newurl
    done
    

    It’s a bit of a hack but it works nicely enough, just cd into the git repo and call git reremote (after making sure it’s in your $PATH and also that you’ve fixed the old and new variables.

    Git Baby is a git and github fan, let's start git clone.