Not in a Git repository, but rather in GitHub specifically - how do I search just the commit messages of a specific repository/branch?
-
3Is the repo public or private? – Sep 05 '13 at 22:03
-
2How about searching for a commit messages in all the forks? Trying to avoid re-inventing the wheel when the main repository has over 100+ forks! – Daniel Sokolowski Aug 05 '14 at 14:43
-
Any changes since then? – Pavel Šimerda Nov 20 '16 at 07:55
-
I want to search the _network_ commits – frumbert Jun 11 '18 at 21:51
-
The new (Jan. 2023) `gh search commit` I [do mention below](https://stackoverflow.com/a/28493853/6309) could be helpful here. – VonC Jan 26 '23 at 00:02
15 Answers
You used to be able to do this, but GitHub removed this feature at some point mid-2013. To achieve this locally, you can do:
git log -g --grep=STRING
(Use the -g
flag if you want to search other branches and dangling commits.)
-g, --walk-reflogs
Instead of walking the commit ancestry chain, walk reflog entries from
the most recent one to older ones.

- 30,738
- 21
- 105
- 131

- 2,877
- 2
- 17
- 10
-
188
-
1
-
15Tip omit the `-g` flag for most common use cases. I haven't looked too much into this, but with `-g`, the search seems to go back only one month. `git log -g --grep=fix` while in the `develop` branch of a repo that has ~8000 commits spanning two years, only goes as far back as Feb 2. – Dan Dascalescu Mar 05 '15 at 00:55
-
1@DanDascalescu Strange, I was able to find commits going back at least 5 months with the `-g` flag. – Chrispy May 26 '15 at 16:11
-
I know this is a bit of an old post, but I just created a project to support this using GitHub webhooks to send pushes for your repositories. It can be found at https://gitlog.devso.io if you're interested – Boardy May 02 '22 at 19:25
-
The `-g` flag will *only* walk reflog entries, not the commit ancestry. The reflogs are the logs of what commits the refs (such as branches) have pointed to over time. That's specific to *your* machine, not what the GH's matching branches have pointed to. So if you've just cloned the repo, `-g` is only searching a single commit: the latest one. That's the only commit a local copy of a branch has ever been at. That's probably not what you want most of the time. – Peeja Jun 20 '23 at 19:15
Update (2017/01/05):
GitHub has published an update that allows you now to search within commit messages from within their UI. See blog post for more information.
I had the same question and contacted someone GitHub yesterday:
Since they switched their search engine to Elasticsearch it's not possible to search for commit messages using the GitHub UI. But that feature is on the team's wishlist.
Unfortunately there's no release date for that function right now.

- 30,738
- 21
- 105
- 131

- 1,739
- 1
- 11
- 12
-
8+1 You have saved me fruitless time in GitHub wondering how to achieve what I supposed would be an obvious piece of functionality. So we now have to clone the repo locally to grep via the command line instead. Jeez, that's progress eh?! ;) – McNab Feb 25 '14 at 13:41
-
82Even their advanced search in the Web UI doesn't permit searching on the most important field - the actual commit message. That is absolutely ridiculous IMO. Github get your act together! – Bradley Thomas May 12 '14 at 12:54
-
24Yes. Forget the fact that they've built a web service that's help to revolutionise and popularise open source software, the fact that they don't have this one feature makes it a complete sham! – Jon Cairns May 30 '14 at 14:52
-
13Thanks for taking the time to publish the content of your discourse with GitHub in an easily findable public place. It's absurd that this is the only way for the public to get such information - it's deeply stupid for GitHub not to have a public issue tracker - but in the presence of such stupidity, what you have done here is a useful way of preventing hundreds of others from wasting time sending in the same request. Thank you for the hundreds of man hours of productivity you have saved. – Mark Amery Dec 26 '14 at 21:35
-
1Well not much better than Atlasian's public tracker, which is full of 7 year old open issues with 1000's of upvotes... – Askdesigners Oct 14 '16 at 13:26
-
If this isn't possible with ElasticSearch, they need to dump ElasticSearch. – Kevin Krumwiede Jul 14 '18 at 21:45
As of 2017 it's a functionality included in GitHub itself.
The example search used by them is repo:torvalds/linux merge:false crypto policy
GIF image from https://github.com/blog/2299-search-commit-messages

- 30,738
- 21
- 105
- 131

- 131,205
- 36
- 218
- 244
-
I get a permission error when searching a private repo I have read / write access to. – fIwJlxSzApHEZIl Dec 13 '17 at 19:17
-
2I've been watching for five minutes and I can't figure out where the mouse goes after it zooms down and to the right. – Kevin Krumwiede Jul 14 '18 at 21:44
-
3
-
The short answer is, you cannot search commit messages directly on github.com the website. For the time being we recommend the local git grep
solution others on this thread have proposed.
At one point in time GitHub did offer a git grep
style search over commit messages for a single repository. Unfortunately, this approach exposed a denial of service that could render a file server inaccessible. For this reason, we removed git grep
searching.
Current back-of-the envelope estimates puts the number of commits in GitHub somewhere around the 80 billion mark. Although Google engineers laugh behind our backs, this is a rather large number of documents to store in ElasticSearch. We'd love to make this dataset searchable, but it is not a trivial project.

- 1,206
- 8
- 4
-
3+1. That seems to confirm what I thought writing [my answer](http://stackoverflow.com/a/28493853/6309): commit message are not indexed: you are working with indexing `git diff's` (meaning the content of the commits, not the commit metadata) – VonC Feb 13 '15 at 17:34
-
How about just "jump to commit" button? Currently it is accessible from URL - http://stackoverflow.com/a/12214817/817632 but there is no interface for it (not that I know of). Use case - find a commit hash somewhere in bower.json instead of version and want to see what this commit does exactly. It will save some time googling. – Olga May 19 '16 at 15:58
This was removed from GitHub. I use:
$git log --all --oneline | grep "search query"
You can also filter by author:
$git log --all --oneline --author=rickhanlonii | grep "search query"

- 20,549
- 7
- 47
- 53
From the help page on searching code, it seems that this isn't yet possible.
You can search for text in your repository, including the ability to choose files or paths to search in, but you can't specify that you want to search in commits.
Maybe suggest this to them?

- 30,738
- 21
- 105
- 131

- 11,783
- 4
- 39
- 66
-
19This seems like the more "default" use case when it comes to searching through a repo. Especially for someone getting to know a new repository with tons of commits. They should definitely consider adding this. – Jose Browne Dec 09 '13 at 21:05
Update January 2023: (eight years later)
With the GitHub CLI gh v2.22.0 (Jan. 2023), you can search from within your local cloned GitHub repository:
See gh search commits
:
Examples:
# search commits matching set of keywords "readme" and "typo"
$ gh search commits readme typo
# search commits matching phrase "bug fix"
$ gh search commits "bug fix"
# search commits committed by user "monalisa"
$ gh search commits --committer=monalisa
Update January 2017 (two years later):
You can now search for commit messages! (still only in the master branch)
February 2015: Not sure that could ever be possible, considering the current search infrastructure base on Elasticsearch (introduced in January 2013).
As an answer "drawing from credible and/or official sources", here is an interview done with the GitHub people in charge of introducing Elasticsearch at GitHub (August 2013)
Tim Pease: We have two document types in there: One is a source code file and the other one is a repository. The way that git works is you have commits and you have a branch for each commit. Repository documents keep track of the most recent commit for that particular repository that has been indexed. When a user pushes a new commit up to Github, we then pull that repository document from elasticsearch. We then see the most recently indexed commit and then we get a list of all the files that had been modified, or added, or deleted between this recent push and what we have previously indexed. Then we can go ahead and just update those documents which have been changed. We don’t have to re-index the entire source code tree every time someone pushes.
Andrew Cholakian: So, you guys only index, I’m assuming, the master branch.
Tim Pease: Correct. It’s only the head of the master branch that you’re going to get in there and still that’s a lot of data, two billion documents, 30 terabytes.
Andrew Cholakian: That is awesomely huge.
[...]
Tim Pease: With indexing source code on push, it’s a self-healing process.
We have that repository document which keeps track of the last indexed commit. If we missed, just happen to miss three commits where those jobs fail, the next commit that comes in, we’re still looking at the diff between the previous commit that we indexed and the one that we’re seeing with this new push.
You do agit diff
and you get all the files that have been updated, deleted, or added. You can just say, “Okay, we need to remove these files. We need to add these files, and all that.” It’s self-healing and that’s the approach that we have taken with pretty much all of the architecture.
That all means not all the branches of all the repo would be indexed with that approach.
A global commit message search isn't available for now.
And Tim Pease himself confirms commit messages are not indexed.
Note that it isn't impossible to get one's own elasticsearch local indexing of a local clone: see "Searching a git repository with ElasticSearch"
But for a specific repo, the easiest remains to clone it and do a:
git log --all --grep='my search'
(More options at "How to search a Git repository by commit message?")

- 1,262,500
- 529
- 4,410
- 5,250
You can do this with repositories that have been crawled by Google (results vary from repository to repository).
Search all branches of all crawled repositories for "change license"
"change license" site:https://github.com/*/*/commits
Search master branch of all crawled repositories for "change license":
"change license" site:https://github.com/*/*/commits/master
Search master branch of all crawled twitter repositories for "change license"
"change license" site:https://github.com/twitter/*/commits/master
Search all branches of twitter/some_project repository for "change license"
"change license" site:https://github.com/twitter/some_project/commits

- 30,738
- 21
- 105
- 131

- 7,676
- 1
- 30
- 52
-
4@DZenBot if it's not a public repo, then you likely already have a local copy to git grep, I just put this answer for those who don't want to clone a whole Public repo to figure out when some change was made. I use it mostly to find commits that remove support for older gtk versions or when licenses change to gpl3 – technosaurus Aug 08 '15 at 04:07
Since this has been removed from GitHub, I've been using gitk
on Linux to do this.
From terminal go to your repository and type gitk
.
In the middle of the GUI, there's a search box. It provides a good selection of filters:
Scope - containing, touching paths, adding/removing string, changing line matching
Match type - Exact/IgnCase/Regexp
Search fields - All fields/Headline/Comments/Committer

- 30,738
- 21
- 105
- 131

- 517
- 3
- 14
This works well from within Eclipse, until GitHub adds the feature:

- 30,738
- 21
- 105
- 131

- 11,488
- 9
- 84
- 97
If you have a local version of the repository, you might want to try this crude shell script I wrote to open the GitHub pages for all commits matching your search term in new tabs in your default browser:
#!/bin/sh
for sha1 in $(git rev-list HEAD -i --grep="$1"); do
python -mwebbrowser https://github.com/RepoOwnerUserName/RepoName/commit/$sha1 >/dev/null 2>/dev/null
done
Just replace https://github.com/RepoOwnerUserName/RepoName/
with the actual GitHub URL of your repository, save the script somewhere (e.g. as githubsearch.sh
, make it executable (chmod +x githubsearch.sh
) and then add the following alias to your ~/.bashrc
file:
alias githubsearch='/path/to/githubsearch.sh'
Then, from anywhere in your Git repository, just do this at the terminal:
githubsearch "what you want to search for"
and any commits that match your (case insensitive) search term will have their corresponding GitHub pages opened in your browser. (Be warned that if your search term appears in hundreds of commits, this may well crash your browser and eat your PC's CPU for a while.)

- 143,130
- 81
- 406
- 459
Using Advanced Search on Github seemed the easiest with a combination of other answers. It's basically a search string builder. https://github.com/search/advanced
For example I wanted to find all commits in Autodesk/maya-usd containing "USD"
Then in the search results can choose Commits from the list on the left:

- 1,920
- 2
- 24
- 34
Here's the quick answer It's possible!!
Simply search like so in the github search box (top left):
repo:torvalds/linux merge:false mmap
i.e:
Read more here

- 41,291
- 27
- 223
- 311
-
1You "Read more here" link is the very first link I mention in my own answer https://stackoverflow.com/a/28493853/6309 – VonC Oct 05 '20 at 14:35
-
@VonC thanks. The critical info that helped me was was a pic of the Github search bar and `repo:torvalds/linux merge:false mmap` to copy to clipboard. Other answers are probably awesome, but I spend >2 min (mostly looking at dates of answers) when all it needed was a 5 second solution – stevec Oct 05 '20 at 14:38
-
No, either that doesn't work on new commits or it requires some amount of days to index commits. Unusable for recent commits. – midenok Oct 18 '22 at 11:56
-
@midenok ugh, I wasn't aware of that. I find GitHub's search quite imperfect at times. – stevec Oct 18 '22 at 12:08
Simple recipe:
- Keyword = "encryption"
- Repo =
https://github.com/excalidraw/excalidraw
- Path+Query =
/search?q=<KEYWORD>&type=commits
Result URL: https://github.com/excalidraw/excalidraw/search?q=encryption&type=commits

- 4,681
- 3
- 17
- 25