1

I have a number of files containing a string foo. Also, I added foo to the new and old files with a certain commit.

I tried Case-insensitive git pickaxe search

git log -S foo -i --oneline

but it shows only commit titles.

I tried

git diff [commit] [prev_commit] | grep foo

but it does not show filenames. I just want to get a list of created or modified files with foo string.

vovan
  • 1,460
  • 12
  • 22

2 Answers2

2

You're just short an option, try with --name-only and it'll show file names.

Romain Valeri
  • 19,645
  • 3
  • 36
  • 61
  • `git log -S foo -i --oneline --name-only` shows all history instead of the only certain commit, but it solves my problem. Thanks! – vovan Apr 15 '19 at 15:39
  • 1
    Just limit to one commit and point to the right one (`-1 `) within your log command : `git log -S foo -i --oneline --name-only -1 ` or alternatively use `git show` – Romain Valeri Apr 15 '19 at 15:43
0

By default, git log does not show the content of the commits, but you were on the good direction:

git log -S foo -i --oneline --patch

the --patch option will show the content of each commit.

EDIT: Actually it is not quite what you needed, as you did not ask for the commit content, just the filenames. If you don't want the content, @RomainValeri's answer is better.

padawin
  • 4,230
  • 15
  • 19