Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transfer gist repo to github

Tags:

git

github

gist

I am working on a small project with gist and since it is growing I would like to put it on github.

Let's suppose that:

  • my gist repo is at: https://gist.github.com/1234
  • my new (empty) repo is at: https://github.com/ChrisJamesC/myNewProject

The ideal solution would be one that pushes my changes on both the gist and the github repository.

like image 959
Christopher Chiche Avatar asked Dec 02 '12 16:12

Christopher Chiche


People also ask

Can you Git clone a gist?

Gists are actually Git repositories, which means that you can fork or clone any gist, even if you aren't the original author. You can also view a gist's full commit history, including diffs.

How do you clone a gist file?

With the URL in your clipboard, open the Gist Dev menu and select the Clone a Gist Repository item. You will then be presented with an input field where you can paste the URL copied from GitHub. Click the Clone button or press enter, and the repository will be cloned to your computer.

How do I push all branches to GitHub?

Pushing all branches to default remote Now you would have to push all commits of all branches with git push --all github . To simplify that aswell you can run git push --all github -u once and now all you'll have to do is git push . This will now by default push all branches to the default remote github.


1 Answers

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

git clone [email protected]:1234.git git remote add github [email protected]: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 github git push gist master     # To gist 

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

like image 172
gzm0 Avatar answered Sep 23 '22 07:09

gzm0