Skip to content

Instantly share code, notes, and snippets.

@ishu3101
Created November 24, 2015 08:35
Show Gist options
  • Save ishu3101/830b556b487de5d69690 to your computer and use it in GitHub Desktop.
Save ishu3101/830b556b487de5d69690 to your computer and use it in GitHub Desktop.
Transfer a gist to a GitHub repository

Transfer a gist to a GitHub repository

clone the gist

git clone https://gist.github.com/ishu3101/6fb35afd237e42ef25f9

rename the directory

mv 6fb35afd237e42ef25f9 ConvertTo-Markdown

change the working directory to the newly renamed directory

cd ConvertTo-Markdown

create a new repository on github
add the github repository as a remote to your checked out gist repository

git remote add github https://github.com/ishu3101/ConvertTo-Markdown

push to the new repository on github

git push github master

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 github master   # To github
git push gist master     # To gist

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

@suntong
Copy link

suntong commented Jun 24, 2019

Thanks!

@jbbarre
Copy link

jbbarre commented Mar 19, 2020

perfect! thanks

@Antar74
Copy link

Antar74 commented Apr 24, 2020

being a noob like myself I got an error trying to follow these steps :(

I got stuck in git remote, first got an error and I panicked and did not write it down but it stated my repository was not empty and prompted me to make a pull first. Then instead of a pull I quit and started my command line again (using mac terminal). Created a new repository as the 4th steps ask, and got stuck again but now with a message that says "remote GitHub already exists. Please help!

@efrecon
Copy link

efrecon commented May 27, 2020

Cool! If you ever wanted to get rid of the gist totally, you could do as follows at the end:

git remote rename github origin
git remote remove gist

And perhaps annotate your gist that it has moved to a project, with a link

@namit343
Copy link

thank you so much!

@davidpinto1979
Copy link

Great! Thanks. Just what I was looking for

@jprivet-dev
Copy link

Thanks 👍

@babakfp
Copy link

babakfp commented May 28, 2022

Does it work fine with a gist containing images and videos?

@CCXXXI
Copy link

CCXXXI commented Sep 1, 2022

@Gesugao-san
Copy link

Thanks 👍

@Gesugao-san
Copy link

Gesugao-san commented Dec 26, 2022

Error while this:

$ git push github master
error: src refspec master does not match any
error: failed to push some refs to 'https://github.com/<redacted>/<redacted>'

But ok when this:

$ git push github
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 757 bytes | 757.00 KiB/s, done.
Total 3 (delta 0), reused 3 (delta 0), pack-reused 0
To https://github.com/<redacted>/<redacted>
 * [new branch]      main -> main

@endolith
Copy link

endolith commented Jan 27, 2023

@CCXXXI Yeah that's way easier. Just one step, no local copy or command line needed.

@jm-janzen
Copy link

Legit.

@rolfen
Copy link

rolfen commented Sep 8, 2023

You could simply use the import function. It works, I just tried:

  • Go to your gist, copy the URL for "Clone via HTTPS"
  • Go to your repositories, click on New then click on the "import a repository" link
  • Paste the URL, choose a name and click on "Begin Import"

@mathieu-aubin
Copy link

Pretty cool, even if the import works, i like the idea of using the CLI as intended

@SunsetSamu
Copy link

SunsetSamu commented Jul 24, 2024

Why not https://github.com/new/import

it works well and simple

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment