Skip to content

Instantly share code, notes, and snippets.

View jbialy's full-sized avatar
🤓

Janusz Bialy jbialy

🤓
View GitHub Profile
@jbialy
jbialy / gitundo.txt
Last active October 19, 2017 15:10
Undo pushed commits in git...
git revert <SHA>
git push
This is Git's safest, most basic "undo" scenario, because it doesn't alter history—so you can now git push the new "inverse" commit to undo your mistaken commit.
git reset <last good SHA> or git reset --hard <last good SHA>
git push -f
git reset rewinds your repository's history all the way back to the specified SHA. It's as if those commits never happened. By default, git reset preserves the working directory. The commits are gone, but the contents are still on disk. This is the safest option, but often, you'll want to "undo" the commits and the changes in one move—that's what --hard does