Transfer gist repo to github Transfer gist repo to github git git

Transfer gist repo to github


You can add the github repository as a remote to your checked out gist repository.

git clone git@gist.github.com:1234.gitgit remote add github git@github.com:ChrisJamesC/myNewProject.git

Push it to initialize the git on github

git push -u github master

If your github repo wasn't quite empty (you created it with a README, license, etc. which you don't mind losing) you will have to do a force overwrite on your push

git push -f -u github master

If you don't want to lose the exiting commits and files, see https://stackoverflow.com/a/40408059/117471

This will also change the upstream of the branch, so github will be default.

You now can rename the remote of gist:

git remote rename origin gist

Each time you make changes (or pull changes from github/gist), you can do:

git push                 # To githubgit push gist master     # To gist

This will also push back your changes to the gist and not only the github repo.


Github now has a new feature - import from another repository. So the steps are much simplified:

  1. Use the import feature and specify the URL of the repository.
  2. Profit!

Update:

You don't have to create a repo. The + button in the top right corner now has 'Import Repository' as an option.

screenshot from github


Clone the gist (e.g. git clone git://gist.github.com/123.git) to your local harddrive, then set the new URL for origin (e.g. git remote set-url origin https://github.com/ChrisJamesC/myNewProject). Push to the new repository (git push origin master). Happy gitting!