Email or username:

Password:

Forgot your password?
Darius Kazemi

`git log -S some_variable_name` returns all commits where `some_variable_name` is in the diff (either removed, added, or modified)

super useful for tracking down regressions where you know the variable that's the culprit

8 comments | Expand all CWs
Darius Kazemi

(of course it doesn't have to be a variable, this works for any string in the diff)

[DATA EXPUNGED]
Joel

@darius Yes! One of my faves, which means I've been bitten by an important nuance:

-S will not find diffs that only *modify* lines involving that variable, because it shows diffs that "change the number of occurrences of the specified string".

If you want to find those cases, you want `git log -G` instead, since it returns "differences whose patch text contains added/removed lines that match".

Heads up that -G takes a regex vs -S taking a substring (altho you can make -S regex with --pickaxe-regex). Fortunately they're right next to each other in `git help log`, which actually has a nice little example showing the difference between the two as well.

@darius Yes! One of my faves, which means I've been bitten by an important nuance:

-S will not find diffs that only *modify* lines involving that variable, because it shows diffs that "change the number of occurrences of the specified string".

If you want to find those cases, you want `git log -G` instead, since it returns "differences whose patch text contains added/removed lines that match".

alx++

@darius Oh nice. I've used `git bisect` a lot for tracking digressions, but that can be pretty heavyweight when you already have some idea of the issue.

ris

@darius sick! a good git log option i also am a big fan of is `git log -L`. you can add this flag and follow it with a function to list only that function's history, which is actually fairly practical in my workflow.

faebser

@darius Do you mainly use git on the command line or do you use something like magit?

Darius Kazemi

@faebser Command line, myself. I don't know anything about the non-CLI ecosystem myself! I bet there's cool stuff out there.

Go Up