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.

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

2 Comments

git log -S foo -i --oneline --name-only shows all history instead of the only certain commit, but it solves my problem. Thanks!
Just limit to one commit and point to the right one (-1 <commitHash>) within your log command : git log -S foo -i --oneline --name-only -1 <commitHash> or alternatively use git show
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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.