April
14th,
2015
- Testing stuff on a old commit
# This will detach the HEAD, i. e., it leaves no branch checked out:
git checkout
# Or:
# This will create a new branch from an old commit. Ideal to play and make new commits.
git checkout -b old-state
- Getting rid of everything done since a specific commit
# If no published commits exist, i. e., it all the commited changes are were not pushed yet!
git reset --hard
- Undo published commits with new commits.
# Delete a commit somewhere in time (the following commits are kept!):
git revert HEAD~2
# Delete the last commit:
git revert HEAD
# Delete the last two commits:
git revert HEAD~2..HEAD