Last active
October 19, 2017 15:10
-
-
Save jbialy/375e6bdec3e6e6814f87d10725fee38a to your computer and use it in GitHub Desktop.
Undo pushed commits in git...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
reference: https://github.com/blog/2019-how-to-undo-almost-anything-with-git |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment