How to safely change github account name?
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:
- Change account name in GitHub settings
- 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?
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 firstname.lastname@example.org:old_account/foo.git
finally add your new remote address:
git remote add origin email@example.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
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.