6

I have a website/repo.

Part of my website says:

"Powered by https://myotherwebsite.com/'"

at some point, some troll I had working on the website switched it to say:

"Powered by https://theirwebsite.com"

How can I search the entire repo history to the commit where this change was made.

There have been A LOT of commits/branches over the years.

Romain Valeri
  • 19,645
  • 3
  • 36
  • 61
J. Doe
  • 169
  • 10

1 Answers1

8

If you can ignore dead branches and assume that all relevant code is reachable from your most recent master version, I'd recommend using the -S option of git log :

git log -S "theirwebsite"

Take a look at the doc, and maybe consider using regexp search if your actual need is or becomes more complex than what you described here.


Even better : with --all you can search your entire repo (thanks to j6t for the trick!)

git log --all -S "theirwebsite"

(and, as noted by vfalcao, consider using the --name-only option here to list files where this change happened.)

Romain Valeri
  • 19,645
  • 3
  • 36
  • 61
  • 2
    The restriction to ignore dead branches is not necessary. Just add `--all` to the suggested `git log` command to search all branches. – j6t Feb 07 '19 at 07:22
  • consider using `git log --all --name-only -S "theirwebsite"`, which is going to list the files changed in each commit as well. It can help you to narrow down the exact changing point. – vfalcao Feb 07 '19 at 10:32
  • @vfalcao Thanks, I had failed to notice your comment at the time! – Romain Valeri Mar 09 '19 at 13:21