1. Advanced Troubleshooting and Cleanup
git reflog -10What it doesDisplays the last 10 HEAD moves to restore commits or branches that were deleted or bypassed with reset
When to use itEmergency moment when code is lost due to --hard reset or wrong rebase
Example
git reflog -10git branch recovery/lost-work <hash>What it doesCreates a new branch starting from any commit hash you found in the reflog
When to use itto save and retrieve a lost work before it is deleted by the Garbage Collector
Example
git branch recovery/lost-work c7a1b2dgit clean -ndWhat it doesDry run display of untracked files and folders that will be deleted without actually deleting
When to use itA mandatory first step before any warehouse cleaning operation
Example
git clean -ndgit clean -fdWhat it doesForcibly delete untracked files and empty folders from Working Tree (dangerous)
When to use itto completely clean up construction waste and temporary experiments
Example
git clean -fdgit clean -fdxWhat it doesDeletes all untracked files including ignored files in .gitignore
When to use itto return the repository to a completely clean state as if it were a fresh clone
Example
git clean -fdxgit bisect startWhat it doesStarts a binary search session to detect the exact commit that entered an error or regression
When to use itWhen you discover a bug in your code and want to know exactly when and by whom it caused it
Example
git bisect start && git bisect bad && git bisect good v1.0.0git bisect resetWhat it doesEnds the bisect session and returns the HEAD to its original location before starting the scan
When to use itAfter finding the commit causing the problem
Example
git bisect reset