Skip to content

Instantly share code, notes, and snippets.

@CristianLlanos
Last active August 30, 2016 03:37
Show Gist options
  • Save CristianLlanos/a509df65f5eb75973a8a to your computer and use it in GitHub Desktop.
Save CristianLlanos/a509df65f5eb75973a8a to your computer and use it in GitHub Desktop.
Undoing things with Git
# 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