Git: Finding changes in ALL commits

Posted . Visible to the public.

Finding changes

When you're looking for a specific change in Git, there are multiple axes you can choose:

  • git log -- path/to/file lists all commits that touch a file
  • git log -S some_string lists all commits where "some_string" was added or removed

Note that you can do most of these things with Git tools as well, e.g. tig path/to/file.

Considering ALL commits

By default, only the current branch (HEAD) is searched. To search across the entire local repository, add these options:

  • --all: Search all known refs (branches, tags, remotes)
  • --first-parent: Simplification for merges
  • --reflog: Search all reflog entries

Example: git log --all --first-parent --reflog -- path-to-file.

Hat tip to BigMiner Show archive.org snapshot .

Considering certain branches

You can use --branches to (only) search all branches. Pass a pattern to filter, e.g. --branches=dominikschoeler or --branches='*1274*'.

Profile picture of Dominik Schöler
Dominik Schöler
Last edit
Dominik Schöler
License
Source code in this card is licensed under the MIT License.
Posted by Dominik Schöler to makandra dev (2025-11-13 09:41)