Troubleshooting
This directory is used for handling high-frequency Git accidents. First, determine the state, then choose a recovery plan; do not copy dangerous commands right away.
Answer Three Questions First
- Has the code been committed?
- Has the commit been pushed?
- Has anyone continued development based on these commits?
The answers to these three questions determine whether you can rewrite history, whether you should use revert or reset, and whether you need to confirm with the team first.
Choose a Plan Based on State
First Aid Entries
Handling Principles
- When unsure, start with
git status, git log --oneline -10, git reflog -10
- Prioritize using
revert on public branches
- Local unpushed errors are easier to clean up
- When secrets are involved, first revoke and rotate keys, then clean up history
- When collaborators are involved, first confirm if anyone is continuing development based on the old commits
Related Content