Skip to content

Instantly share code, notes, and snippets.

@aeinbu
Last active August 16, 2024 09:13
Show Gist options
  • Save aeinbu/7242425f954cb21d28074e079fb17559 to your computer and use it in GitHub Desktop.
Save aeinbu/7242425f954cb21d28074e079fb17559 to your computer and use it in GitHub Desktop.

Different ways to search a git repo

git log -S "..."
git log -S "..." --pickaxe-regex
git log -G "..."
git log --grep="..."

See docs for

  • git log -S <string> will look for the commits that changes the number of occurrences. This will find when something was added or removed, but not just moved to somewhere else inside the same commit.
  • git log -S <regex> --pickaxe-regex Same as above, but with regex support
  • git log -G <regex> will look for the commits where a change involves this regex or text. It will find when it has been moved, as well as added or removed.
  • git log --grep=<pattern> searches in commit messages only
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment