Last active
August 30, 2016 03:37
-
-
Save CristianLlanos/a509df65f5eb75973a8a to your computer and use it in GitHub Desktop.
Undoing things with Git
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
# Undo commit (it does not delete your changes) | |
git reset --soft HEAD~1 | |
# Undo add (it does not delete your changes, only unstages them -> red color) | |
git reset --mixed | |
# Save changes to a temporary commit (takes out your changes for a while) | |
git stash | |
# change branch | |
git checkout <branch_name> | |
# restore changes on a branch (fetches your changes) | |
git stash pop | |
# Undo merge | |
git reset --merge ORIG_HEAD | |
# Change active branch's name | |
git branch -m <newname> | |
# Change another branch's name | |
git branch -m <oldname> <newname> | |
# Delete branches | |
git branch -d <branch-name> | |
git push origin --delete <branch-name> | |
# Find staged submodules | |
git ls-files --stage | grep 160000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment