Migrating Github Projects to HTTPS
Message from 2022
This post is pretty old! Opinions and technical information in it are almost certainly oudated. Commands and configurations will probably not work. Consider the age of the content before putting any of it into practice.
Github now has an HTTPS repository URL for every project, and you should definitely use it. You don’t have to manage SSH keys, just store your password in plain text1 in your home directory.
Once per machine, put this in your ~/.netrc file:
machine github.com
login bkerley
password yourpassword
For each repo, do this:
> git remote rm origin
> git remote add origin https://github.com/bkerley/yourproject.git
> git remote set-branches origin
> git pull origin master
From https://github.com/bkerley/yourproject
* branch master -> FETCH_HEAD
Already up-to-date.
>
And that’s basically it.
Footnotes
1: Github crew, can we get a way to use our API token or some other revokable token as a password for HTTPS repo operations? I appreciate that anything involving “revokable tokens” is really hard to make a decent UI for, but it just feels bad keeping that in my .netrc file.