Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I pass a string to git log -S instead of just a word?

Tags:

git

git-log

I wanted to search for the commit that either contains the string "hello world" or any commit that included that phrase inside of a file.

git log -SHello World doesn't work

git log -S'Hello World' doesn't work

git log -S"hello world" doesn't work

I have been using: git log -i --grep='hello world' but this one only works for commit messages.

like image 927
VaTo Avatar asked Dec 04 '15 20:12

VaTo


People also ask

What is git log -- Oneline?

Git Log OnelineThe oneline option is used to display the output as one commit per line. It also shows the output in brief like the first seven characters of the commit SHA and the commit message. It will be used as follows: $ git log --oneline.

What are the 40 character strings of letters and numbers that appear in git log called?

"SHA" stands for Simple Hashing Algorithm. The checksum is the result of combining all the changes in the commit and feeding them to an algorithm that generates these 40-character strings. A checksum uniquely identifies a commit.

How do I jump out of git log?

You can press q to exit. git hist is using a pager tool so you can scroll up and down the results before returning to the console.

What should I write after git log?

Check Commit History: This will show you all the commit messages, authors name, and email, as well as the date and time they were committed. There one thing that frustrates many beginners about using git log or git diff they can't figure out a way to exit commit log. To exit git log, type “q” or “z”.


1 Answers

The pickaxe search (git log -S) looks for the addition or removal of a word in a commit (and not in a commit message).
See the comment on this answer.

If you have a commit message which includes that word, but the commit content itself does not have "hello world" as being added or removed (meaning, for instance, it is already there, from previous commits), that commit would not be reported.

Other than that, git log -S 'This repos' or git log -S'This repos' should work just fine.

like image 148
VonC Avatar answered Sep 20 '22 00:09

VonC