11

I am trying rollback a Gist to an older state through either the web interface or the Github Desktop app. I've seen solutions that seem to show how one might do this using the command line. However, I can't figure out how one can do this without using the Command Line Interface.

Is the CLI the only way to rollback history? If so, is there a reason for this limitation of the web interface and desktop app?

Community
  • 1
  • 1
skube
  • 5,867
  • 9
  • 53
  • 77
  • 2
    By "rollback", do you mean revert commit(s) or reset (i.e. *delete* recent history) ? I can't think of a way to do either using the GitHub web interface alone. – jub0bs Sep 02 '15 at 11:30
  • what do you have against the CLI? – U r s u s Sep 02 '15 at 11:31
  • @Jubobs: I mean to set my state to a state back in time, essentially erasing all commits – skube Sep 02 '15 at 11:33
  • @Ursus: I have nothing against CLI, I just find it odd going back in time can't be done in 2/3 of the tools available. – skube Sep 02 '15 at 11:34
  • "If so, is there a particular, fundamental reason for this limitation of the web interface and desktop app that I simply don't understand?" Yes. The fundamental limitation is "that's the way the GitHub developers wanted it." – larsks Sep 02 '15 at 11:46
  • Can you shed some further insight or reasoning? – skube Sep 02 '15 at 13:06
  • Windows 7 or later try using https://desktop.github.com/ which gives you a decent set of tools and options for the platform. you can see what defaults was prefered during my install in this other issue https://github.com/mbostock/gistup/pull/25#issuecomment-143466842 which involves Gist – CrandellWS Sep 28 '15 at 08:40

3 Answers3

8

git clone

Use one of the following URIs to clone your git

$ git clone git@gist.github.com:<gist_hash>
$ git clone git@github.com:<gist_hash>.git

# navigate to directory
$ cd <gist_hash>

rebase

Update your branch however you'd like, using rebase for example

$ git rebase --interactive
pick 8c199dc 8c199dc373b5be96df92131e3c0631514636583d
- pick dc968d3 dc968d3e2cb3a571ed50233047c3d83ba3f6e209

force push

You'll have to force push up your changes to overwrite previous commits

$ git push -f
KyleMit
  • 30,350
  • 66
  • 462
  • 664
1

I mean to set my state to a state back in time, essentially erasing all commits

That is called a git reset, and generally frowned upon whenever there is collaboration on the same remote repo: a git push --force publishes the revised history, and forces everyone else to carefully reset his/her own clone in order to not re-introduce by mistake the deleted commit.

That is why such a feature is not exposed in a GUI.
Although, when it comes to gists (generally managed only by their GitHub account owner), one might consider allowing an easier reset through the GUI.
Yet, that is not the case right now, probably to keep the user interface coherent between GitHub for Desktop for regular GitHub repos and for gist repos.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
1

I would do it manually by finding the revision I want to revert to, copying the markdown of that revision and create a new revision with that markdown.

  1. Click the "Revisions" tab
  2. Scroll down to the revision I want to revert to
  3. Click the "View" button to see the html of a revision
  4. Click the "Raw" button to see the markdown of the revision
  5. Copy that markdown
  6. Click the "Edit" button, paste that markdown and click the "Update" button
mnishiguchi
  • 2,051
  • 23
  • 17