Skip to content

Instantly share code, notes, and snippets.

@eduncan911
Last active July 20, 2023 09:41
Show Gist options
  • Star 51 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save eduncan911/7c7ddb02b16ed83478e22aa4d209b17f to your computer and use it in GitHub Desktop.
Save eduncan911/7c7ddb02b16ed83478e22aa4d209b17f to your computer and use it in GitHub Desktop.
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 clone git@github.com:cc13e0fcf2c348cc126f918e4a3917eb.git

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!

@ysnotksk
Copy link

Thanks! You helped me out a lot :)

@bradmccormack
Copy link

Cheers !

@mkvlrn
Copy link

mkvlrn commented Oct 23, 2019

Life saver!

@rainabba
Copy link

Just what I was needing!

@marco-souza
Copy link

Ty, works for me! 🎉

@bruteforks
Copy link

new version since name change master -> main
git push -f origin main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment