Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to upload one file repository to Gist, preserving history?

Tags:

I have a Git repository on my computer with a single file coins.py

How can I get that as a Gist on Github, preserving history?

like image 222
Colonel Panic Avatar asked May 11 '13 17:05

Colonel Panic


People also ask

How do I upload a file to GitHub gist?

Go to your Gist and click the Edit button at the top right. The Gist editor will show your files in edit mode, then look at the bottom left and there you will find an 'Add file' button. Click it and the cursor will be moved to the 'File name box..', type a name and click the 'Update gist' button at the bottom right.

What is the difference between Gist and repository?

Gist is a simple way to share snippets and pastes with others. Whereas Repo is simply a place where the history of your work is stored.


1 Answers

This is actually quite simple. You can move your existing history into a Gist repo like you would move it into any other:

  1. Create a Gist (simply enter a few random characters, so it gets created; enter a title if you want)
  2. Copy the URL of the newly created Gist (it has the form https://gist.github.com/<LONG-HEXNUMBER>.git (if you prefer using SSH URLs, you can use [email protected]:<THAT-SAME-HEXNUMBER>.git instead)
  3. In your existing local repo, do git remote add origin <URL>, where origin is an unused local name for the remote
  4. Push your changes: Assuming you have a local master branch, you will want to overwrite the remote one with git push -f origin master
  5. Push any other branches or tags you want on the remote as usual.
like image 143
Nevik Rehnel Avatar answered Oct 22 '22 23:10

Nevik Rehnel