Created
May 20, 2023 16:41
-
-
Save moonraker22/229b6299f3629018e31cb8b5031dc165 to your computer and use it in GitHub Desktop.
revert commit safely
This file contains hidden or 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
| # Create a backup of master branch | |
| git branch backup_master | |
| # Point master to '56e05fce' and | |
| # make working directory the same with '56e05fce' | |
| git reset --hard 56e05fce | |
| # Point master back to 'backup_master' and | |
| # leave working directory the same with '56e05fce'. | |
| git reset --soft backup_master | |
| # Now working directory is the same '56e05fce' and | |
| # master points to the original revision. Then we create a commit. | |
| git commit -a -m "Revert to 56e05fce" | |
| # Delete unused branch | |
| git branch -d backup_master |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment