When you are tracking down a bug or trying to understand why a specific change was made, Git offers powerful archaeology tools like grep and bisect.
git grep is incredibly fast because it only searches through files tracked by Git, ignoring .git/ directories and built binaries entirely.
git grep $opts -e "$pattern"git bisect uses binary search to find the exact commit that introduced a bug. You first start the bisect and then mark a known bad commit and a known good commit.
git bisect startMark the commit where the bug is currently happening. Usually this is your current HEAD.
git bisect bad $commitMark a commit from the past where you know for a fact the bug did not exist. Git will then checkout a commit halfway between the good and bad commits.
git bisect good $commitTest the codebase at the newly checked out commit. If the bug is present, mark it bad. If it works, mark it good. Git will continue narrowing down the commits until it finds the exact culprit.
git bisect $statusOnce Git prints out the exact commit that caused the bug, use this command to end the bisect session and return your repository to where you started.
git bisect reset