my-git

Troubleshooting

English 中文

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

  1. Has the code been committed?
  2. Has the commit been pushed?
  3. 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

Current State Recommended Entry
Code not yet committed Undo Anything
Committed, not yet pushed Git Troubleshooting Playbook
Pushed Git Troubleshooting Playbook, Revert Merge Commit
Used as a base for further development by others Git Troubleshooting Playbook
Secret has been committed Remove Secret from History
Force push overwrote remote Recover Force Push

First Aid Entries

Problem I’m Facing Recommended Reading
Unsure how to recover Git Troubleshooting Playbook
Committed to the wrong branch Committed to Wrong Branch
Want to undo an operation Undo Anything
Cannot find a commit Recover Lost Commit
Force push overwrote remote Recover Force Push
Discovered an incorrect merge Revert Merge Commit
Conflict resolution is messed up Resolve Conflicts
Secret committed into history Remove Secret from History

Handling Principles