Search a git repo
travisjeffery.com
travisjeffery.com
git log -S"pattern"
This is useful for searching diffs. If your repo is small this is quite fast. However for large repos, it can be slow which is why I use my own diffs indexer. Below is a screenshot of what my diffs search looks like.
http://screenshots.gitsense.com/diffs-search.html
For most people, git log -S should work fine but my solution is targeted for enterprise, which is why I went my own route.
The article includes git log -G"pattern". git log -S"string" it limited to a string.
I wasn't aware that `git grep` was as customizable as is shown in the article. I tend to use `ag` (the silver searcher) instead of regular grep, which besides being fast produces nice colored output. Here's a `zsh` function I put into my ~/.zshrc which allows me to apply ag only to files tracked by git: https://gist.github.com/pesterhazy/9294048
In fact, the author used `git grep` to benchmark against: http://geoff.greer.fm/2011/12/27/the-silver-searcher-better-...
I have never understood why --with-pcre is not the default in Homebrew, --without-pcre should be the option.
I got this fancy shiny Macbook (with a broken keyboard, but who cares…) from IT and it might actually make sense to use it sometimes, but I don’t really want to go through the hassle of registering with Apple just to get a recent-ish Bash, git etc. The instructions on the website seem to require Xcode to be installed, which seems to only be available via iTunes.
Does that perhaps answer your question?
git rev-list --all | (while read rev; do git grep -e <regexp> $rev; done)
The '--all' argument tells rev-list to emit the history of every single ref. You probably only want a branch. Also, this is a job for xargs: git rev-list master | xargs git grep -e <regexp>Didn't we make a pact to stop using "ninja" and "rock star"? Excepting, of course, an interviewee who a) arrives in the conference room via the air ducts while the the interview's back is turned, or b) who snorts lines of coke off the whiteboard tray and then smashes holes in the sheetrock walls with a Fender Stratocaster.