Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Search for a string in all diffs in a repo

Search through diffs

To make case-insensitive, add -i to all grep and git log commands

Search for "Telescope" (case sensitive) in all diffs in a repo

$ git log -STelescope

Result is something like this:

commit c8eb8ffa9a98633ef5ec43e8653a67699cc5f53e (HEAD -> master)
Author: jakebathman <jake.bathman@gmail.com>
Date:   Tue Nov 27 10:23:56 2018 -0600

    Installed Laravel Telescope

See files changed

$ git show c8eb8ffa9a98633ef5ec43e8653a67699cc5f53e | grep -E "diff --git .+$" -A 4

Result:

diff --git a/app/Providers/TelescopeServiceProvider.php b/app/Providers/TelescopeServiceProvider.php
new file mode 100644
index 0000000..5e2acfd
--- /dev/null
+++ b/app/Providers/TelescopeServiceProvider.php
--
diff --git a/composer.json b/composer.json
index 1b9639f..9e4703f 100644
--- a/composer.json
+++ b/composer.json
@@ -19,12 +19,14 @@
--

...

See matching lines in diff

Adding diff --git as a grep match option adds the file as context above matching lines

$ git show c8eb8ffa9a98633ef5ec43e8653a67699cc5f53e | grep -E "(diff --git .+$|Telescope)"

Result:

    Installed Laravel Telescope
diff --git a/app/Providers/TelescopeServiceProvider.php b/app/Providers/TelescopeServiceProvider.php
+++ b/app/Providers/TelescopeServiceProvider.php
+use Laravel\Telescope\EntryType;
+use Laravel\Telescope\Telescope;
+use Laravel\Telescope\IncomingEntry;
+use Laravel\Telescope\Contracts\EntriesRepository;

...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.