Posting this as a reference for my future self, so I don't have to search every time.
git commit
git commit --amend
will update and replace the most recent commit with a new commit that combines any staged changes with the contents of the previous commit. With nothing currently staged, this just rewrites the previous commit message.git merge
-m 1
option tells Git that we want to keep the parent side of the merge (which is the branch we had merged into). Finally, also make sure to provide the correct commit hash: when using git revert, we have to specify the actual merge commit's hash.git push
git add
git checkout
git pull
git reflog
git reset --hard [email protected]{"5 minutes ago"}
git branch -D
deletegit reflog
to get the commit SHA before you deleted the branchgit reset
git reflog
git reset
to reset :)git stash pop/drop/clear
git stash apply
Make sure that diff coloring is set to auto in your.gitconfig
otherwise the command will fail with unrecognised input.
Only works for annotated tags, tags created usinggit tag -a
git fsck
to check for dangling/unreachable commits.git tag -l
to verifygit restore
to restore the file :)Undoing a git merge is a risky business. Please proceed with caution
ORIG_HEAD
points to the original commit before the merge. So we are just resetting that