Last active
February 23, 2018 19:00
-
-
Save limafm/2053b05dc9d5de5e57bbc75761950f09 to your computer and use it in GitHub Desktop.
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
UNDO A LAST LOCAL COMMIT | |
# use --soft if you want to keep your changes | |
git reset --soft HEAD^ | |
# use --hard if you don't care about keeping the changes you made | |
git reset --hard HEAD^ | |
--------------------------------- | |
UNDO A LAST PUBLIC COMMIT | |
git revert HEAD | |
--------------------------------- | |
FIX UP THE MOST RECENT COMMIT | |
git commit --amend | |
--------------------------------- | |
REMOVE A REMOTE BRANCH | |
git push origin :<branch_name> | |
--------------------------------- | |
REMOVE FROM YOUR TREE DELETED REMOTE BRANCHES | |
git remote prune origin | |
--------------------------------- | |
CHECKOUT A SINGLE FILE TO A SPECIFIC BRANCH | |
git checkout <BRANCH> -- <fILE> | |
(you need to commit it again) | |
--------------------------------- | |
UNDO A MERGE (before push) | |
git reflog | |
# use the id of the commit what you want to undo | |
git reset --hard 36a18be | |
--------------------------------- | |
REMOVE A LOCAL TAG | |
git tag -d <tagname> | |
--------------------------------- | |
REMOVE A REMOTE TAG | |
git push origin :<tagname> | |
or | |
git push --delete origin <tagname> | |
--------------------------------- | |
RESET HARD!!! | |
git checkout master | |
git reset --hard 7a62674ba3df0853c63539175197a16122a739ef | |
git push -f origin master | |
--------------------------------- | |
Change the mergetools editor | |
git config --global core.editor "vim" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment