↑ ↓ select, Enter open, Esc close

Search for text in all versions of a repository

Adjust the values, the command updates live
user@server
git rev-list --all | xargs git grep -F 'DB_PASSWORD'

Passes all commits of the repository to git grep, which searches every snapshot for the fixed search string (-F). Each matching line starts with the commit hash and file path. Useful for checking whether credentials or certain code were ever in the repository, even if they have since been deleted.

Note: On large repositories with many commits this can take a long time and produce a huge number of matches, because unchanged files reappear in every commit. To narrow down when something happened, git log -S is better suited.

Also searched as

  • git search all commits for string
  • find password committed to git history
  • git grep entire history

Related one-liners

All in Git

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.