git-fix-it
Something went wrong in Git and you want to get out without making it worse. Type what happened: "wrong branch", "undo commit", "conflict", "rejected". Each entry says what the command does to your work before you run it.
three rules that prevent most damage
- Look before you leap:
git statusandgit log --oneline -5first. Most accidents happen on the wrong branch. - Committed work is nearly impossible to lose. Uncommitted work is gone the moment you discard it. When in doubt, commit or stash before you try something.
- Never rewrite what others have pulled. On a shared branch, fix mistakes with a new commit (
git revert), not with reset, amend or force push.
abc1234 stands for a commit ID from git log. A cheap insurance before any risky command: git branch backup-before-fix marks where you are, and you can always come back to it. Related: Git cheat sheet, Bash and PowerShell side by side, Ansible cheat sheet.