summaryrefslogtreecommitdiff
path: root/src/content/tils/2020/10/11/search-git-history.adoc
blob: 06df9dc23b5a40901e3de526aca1c8d352c2a997 (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
= Search changes to a filename pattern in Git history
:categories: git

:yet:     link:../../08/14/browse-git.html
:another: link:../../08/16/git-search.html
:entry:   link:../../08/28/grep-online.html

This is {yet}[yet] {another}[another] {entry}["search in Git"] TIL entry.  You
could say that Git has a unintuitive CLI, or that is it very powerful.

I wanted to search for an old file that I new that was in the history of the
repository, but was deleted some time ago.  So I didn't really remember the
name, only bits of it.

I immediately went to the list of TILs I had written on searching in Git, but it
wasn't readily obvious how to do it, so here it goes:

[source,shell]
----
git log -- *pattern*
----

You could add globs before the pattern to match things on any directory, and add
our `-p` friend to promptly see the diffs:

[source,shell]
----
git log -p -- **/*pattern*
----