Created
July 3, 2018 11:45
-
-
Save rezamt/9d382c886f7d1a874c9032c89a6ee06f to your computer and use it in GitHub Desktop.
Git Reset and Hash
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
# 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 | |
# you can also use the full hash | |
git reset --hard 56e05fcec80a0aff84cf05ea030c7e478129905 | |
# 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