Pitfalls when Renaming your GitHub Account

Multithreaded JavaScript has been published with O'Reilly!

So, you've decided to rename your GitHub account to something else, and you're not too sure how much danger you've got in store for yourself eh? Well, lucky you, I just did a GitHub account rename (from renownedmedia to tlhunter) and I'm here to tell you everything to look out for. It's really not as simple as you might think, and there are a few things GitHub should do to make the process smoother, but they don't.

From what I can tell, their Wiki software takes your markup (or markdown, as it were), and converts it to HTML as soon as you save it. This is fine and makes sense, the server shouldn't be compiling markdown syntax into HTML with every page render. However, this also means they store a copy of your local links using the [[PageName]] syntax. Unfortunately, when you change your username, they don't re-generate the pages to fix those links.

The easiest solution is to go through your wiki, edit and save each page. You don't actually have to make any changes to the pages; just click edit then save. Also, if you have normal URLs in your page (e.g. starting with http), you will of course need to manually change those by hand.

Local Repositories Need Updates

This one is probably pretty obvious. Your local git repositories are now pointing to an invalid remote location. Luckily these are pretty easy to fix. Go into the root of your repository, and edit the .git/config file. Then, do a search for the old username, and replace it with the new one. This will also fix any submodules you have locally.

If you make updates to the submodules, don't forget to push them live, so others can pull and have the proper remote locations.

[remote "origin"]
  url = git@github.com:tlhunter/Cobalt-Calibur-3.git
  fetch = +refs/heads/*:refs/remotes/origin/*
[submodule "system"]
  url = git@github.com:tlhunter/sleekmvc.git

Update .gitmodules

Edit your .gitmodules file to also contain the new location, similar to what you did above in the .git/config file.

Change GitHub Local Username

If part of your username change is that your email or name have also been changed, you'll want to tweak your GitHub configuration locally.

git config --global user.name "Firstname Lastname"
git config --global user.email "your_email@youremail.com"

This one is also a given but it's probably worth mentioning. The URL which people will visit is now pointing to a location which doesn't exist. GitHub doesn't do anything convenient here like redirect the old URL to the new URL for a grace period (and even if they did you would still need to fix this). So, in any of your blogs, forum posts, email signatures, you name it, you will want to update the URL to point to the new location of your GitHub account.

Search Engine's Results

For this issue, there really isn't anything you can do. Just keep in mind that search engines will now take users to the wrong location. This should hopefully be fixed in about a week, but it really depends on the number of websites pointing to your repo's, as well as the number of people visiting them. Higher profile accounts will likely have their search entries updated quicker.

Update README Files

A lot of times our README files will point to our repo's, or our wiki's, etc. You will want to edit these files as well, along with any other files inside of your repository. GitHub makes it convenient to edit a file in your browser and make it a separate commit, this may be the quickest way to do it depending on where you are when you make the account change.

Tags: #git #github
Thomas Hunter II Avatar

Thomas has contributed to dozens of enterprise Node.js services and has worked for a company dedicated to securing Node.js. He has spoken at several conferences on Node.js and JavaScript and is an O'Reilly published author.