Transfer gist repo to github

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:

  • Git gist - Markdown does not work
  • How to embed only certain lines from a gist?
  • Fork Gist to Repo on GitHub
  • Is there a way to specify the width of an embedded gist?
  • What are the green and red gems beside Github Gist Revisions
  • how to create a gist in github that returns json data
    • 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.

  • When would you use the different git merge strategies?
  • Git ignore is not ignoring the netbeans private files
  • How do I cat revisions of a file, following it through renames?
  • Trying to migrate to Github from Bitbucket, getting file size error
  • Combine a base project that is growing in child projects in git repository except git submodule or subtree merge methods
  • How to create a git commit with date in the past?
  • 6 Solutions collect form web for “Transfer gist repo to github”

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

    1. Create a new, blank repository
    2. Use the import feature and specify the URL of the repository.
    3. 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

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

    git clone git@gist.github.com:1234.git
    git 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 github
    git push gist master     # To gist
    

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

    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!

    Sorry for shaking an old question, and that I can’t comment, but in the second step as given by gzm0 you may have to use –force, i.e.

    git push -f -u github master
    

    It may have been because there was a README in the Github repo, but I guess others may run into this too.

    You can clone the gist locally.

    Add the github repository as new remote.

    Push your local repository to the new github remote.

    Delete all files in your gist but the README.md file . in this file you can write a hint that the gist has moved to a new repository

    My edit to the accepted answer was getting lengthy so I created a separate answer to hold it.

    If your repo is not empty and you don’t want to lose the exiting commits and files, the accepted answer doesn’t apply to you. You will have to either:

    1. If you do not care about the commit history of the gist…
      • Copy the files over, git add, git commit
    2. If you want to keep the commit history of the gist…
      • Use git cherry-pick or format-patch which is outside of the scope of this answer. See Is it possible to cherry-pick a commit from another git repository?
    Git Baby is a git and github fan, let's start git clone.