Skip to content

Instantly share code, notes, and snippets.

@jakebathman
Created November 27, 2018 16:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jakebathman/ed6f7bc61eb68e9ede34dcbca6fab86d to your computer and use it in GitHub Desktop.
Save jakebathman/ed6f7bc61eb68e9ede34dcbca6fab86d to your computer and use it in GitHub Desktop.
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