A timeout changed, but searching Git history for the timeout variable returns only its introduction and removal. The missing edit may have preserved the number of occurrences of that variable. Choose the search according to what changed: an occurrence count, a changed line, or the behavior exposed by a test.
This exercise uses a synthetic three-commit repository to distinguish those questions. It assumes PowerShell and Git 2.45 or later. It changes only a newly created exercise directory and uses no remote repository. The result is a candidate commit to investigate, rather than proof that the commit caused a production regression.
Match the question to the search mechanism
The Git log manual defines -S as selecting differences that change the number of occurrences of a string in a file. It defines -G as selecting differences with added or removed patch lines matching a regular expression. Those predicates can select different commits even when the same token appears in both commands.
Use a literal occurrence search when asking when a specific identifier or exact code fragment appeared or disappeared. Use a patch-line search when asking which edits touched lines containing an identifier. Neither predicate evaluates the program. A changed comment, test, or unused declaration can match without changing the behavior being investigated.
Start with a known path and reachable branch tip when possible. Searching every available reference can produce useful leads, but it also introduces abandoned implementations and experiments. Record the search scope alongside the result so another developer can distinguish an absent match from an unsearched branch.
Reproduce a count-preserving edit
Open PowerShell in a new empty parent directory reserved for this exercise. Create the repository and establish its initial value:
git init -b main pickaxe-demo
Set-Location pickaxe-demo
git config user.name "Example Author"
git config user.email "author@example.com"
Set-Content -LiteralPath settings.js -Encoding ascii -Value 'export const delay = 100;'
git add -- settings.js
git commit -m "Introduce delay"
Make one value change, then rename the variable in a separate commit. These are deliberately separate operations so each search result has one explanation:
Set-Content -LiteralPath settings.js -Encoding ascii -Value 'export const delay = 200;'
git add -- settings.js
git commit -m "Increase delay"
Set-Content -LiteralPath settings.js -Encoding ascii -Value 'export const wait = 200;'
git add -- settings.js
git commit -m "Rename delay"
git log --format=%s -S'delay' -- settings.js
git log --format=%s -G'delay' -- settings.js
The occurrence search returns the introduction and rename commits. It omits Increase delay: the file contained one occurrence before that edit and one afterward. The patch-line search includes all three commits because each changes a line containing the token. These results were reproduced with Git 2.45.2 on Windows.
The missed middle commit is the meaningful failure case. A clean occurrence-search result cannot establish that the value never changed. Conversely, the broader patch-line result still needs inspection; finding the word is only the selection condition.
Narrow an empty result without inventing certainty
If a search produces nothing useful, inspect its assumptions before broadening everything. Confirm the spelling in an earlier revision. Check whether the file lived elsewhere. Consider whether behavior moved behind another identifier or into generated output. A literal string does not track a concept across arbitrary rewrites.
Regular expressions introduce another interpretation boundary. In the example, delay has no special regex characters. A fragment containing parentheses or brackets needs deliberate regex treatment for -G; shell quoting alone does not make a regex literal. Keep the search expression visible in the investigation record instead of describing it loosely as a search for the function.
For a suspected rename, inspect nearby commits and paths rather than assuming one file restriction covers the whole lifetime. Merge history also deserves attention: a simplified path history can hide context needed to understand integration. Explain the actual revision range used before claiming that a repository contains no relevant change.
Turn the match into a falsifiable hypothesis
Inspect the synthetic candidate through an exact revision expression:
git show HEAD~1 -- settings.js
git status --short
The patch should show the value moving from 100 to 200, and status should remain clean. Inspection reads committed history; it does not alter the working tree or index. Before testing an older revision in a real project, preserve unfinished work and use a separate checkout or worktree with the dependencies that revision requires.
Write the behavioral hypothesis in observable terms. For example, a test might assert that a retry waits for the configured interval rather than merely checking that the token exists. Run it on both sides of the candidate. If both pass, investigate other changes or revise the hypothesis. If the project cannot build at the old revision, retain that limitation instead of treating the unexecuted test as evidence.
When there are many plausible commits and a reliable pass/fail test, the Git bisect guide supplies the next investigation method. Pickaxe narrows history by textual changes; the test establishes whether a candidate changes the promised behavior. Keep the disposable repository only as long as needed, then remove its exercise directory after leaving it and confirming the target.
Was this guide useful?
Your rating helps us prioritize clearer, more practical technical content.
Review diffs, run checks, and prepare the release in Arezgit.
Keep Git review, security scanning, API checks, database inspection, and release preparation together in one local desktop application.
Explore Arezgit