1. Advanced Workflows & Recovery
git statusWhat it doesChecks the status of the work folder and supply index before making any corrective decision
When to use itThe obligatory first step before any historical recovery or modification
Example
git statusgit diff --cachedWhat it doesDisplays the changes prepared in Staging that will go into the next commit
When to use itto verify changes before pressing commit
Example
git diff --cachedgit reflog -10What it doesDisplays the history of HEAD cursor transactions locally, allowing recovery of commits not visible in the regular history
When to use itWhen a commit is lost after an incorrect rebase or accidental reset
Example
git reflog -10git branch --show-currentWhat it doesPrints the exact name of the currently active branch to avoid making errors on an unintended branch
When to use itIn scripts or for verification before executing push or merge orders
Example
git branch --show-currentgit switch -c recovery/my-workWhat it doesCreates a temporary emergency branch that saves the current state before trying dangerous debug commands
When to use itAs a precaution before complex Rebase or Revert operations
Example
git switch -c recovery/backup-before-rebasegit branch recovery/previous-state <hash>What it doesCreates a new branch that points directly to the commit hash found in the reflog
When to use itto rescue missing code that was present in an undo commit
Example
git branch recovery/lost-commit a1b2c3dgit push --force-with-leaseWhat it doesUnloads historical modifications while checking that there are no new external modifications on the remote branch
When to use itAfter safely rewriting your branch history (such as an interactive rebase)
Example
git push --force-with-lease origin feature/login