Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Revert Gist Commits

Revert / Undo a Gist Commit

It was not exactly obvious. Here's how to revert a Gist commit!

Checkout the gist like a normal git repo:

# replace the Gist ID with your own
git glone git clone

Treat it like a normal repo. Edit, force push, etc.

Force Push

When you are ready, you will need to force push as the remote has newer commits:

git push -f origin master

Example: Revert the last commit to your Gist

Want to revert the last change?

git reset --hard HEAD~1 && git push -f origin master

Yay! You reverted!


This comment has been minimized.

Copy link

commented Sep 5, 2018

Odd this can't be done in the GitHub web interface!

I've never actually used terminal Git for writing a Gist! :)


This comment has been minimized.

Copy link

commented Nov 29, 2018

This is excellent! I also didn't think of gists as normal git repos. I'm sure it's clear to everyone but in case you're a newbie like me and just assumed you'd never heard of git glone there is a typo above. It should be just:

git clone
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.