File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ variety of languages and technologies. These are things that don't really
77warrant a full blog post. These are mostly things I learn by pairing with
88smart people at [ Hashrocket] ( http://hashrocket.com/ ) .
99
10- _ 507 TILs and counting..._
10+ _ 508 TILs and counting..._
1111
1212---
1313
@@ -134,6 +134,7 @@ _507 TILs and counting..._
134134- [ Excluding Files Locally] ( git/excluding-files-locally.md )
135135- [ Find The Initial Commit] ( git/find-the-initial-commit.md )
136136- [ Grab A Single File From A Stash] ( git/grab-a-single-file-from-a-stash.md )
137+ - [ Grep For A Pattern On Another Branch] ( git/grep-for-a-pattern-on-another-branch.md )
137138- [ Grep Over Commit Messages] ( git/grep-over-commit-messages.md )
138139- [ Ignore Changes To A Tracked File] ( git/ignore-changes-to-a-tracked-file.md )
139140- [ Intent To Add] ( git/intent-to-add.md )
Original file line number Diff line number Diff line change 1+ # Grep For A Pattern On Another Branch
2+
3+ Git has a built-in ` grep ` command that works essentially the same as the
4+ standard ` grep ` command that unix users are used to. The benefit of
5+ ` git-grep ` is that it is tightly integrated with Git.
6+ You can search for occurrences of a pattern on another branch. For example,
7+ if you have a feature branch, ` my-feature ` , on which you'd like to search
8+ for occurrences of ` user.last_name ` , then your command would look like this:
9+
10+ ``` bash
11+ $ git grep ' user\.last_name' my-feature
12+ ```
13+
14+ If there are matching results, they follow this format:
15+
16+ ```
17+ my-feature:app/views/users/show.html.erb: <%= user.last_name %>
18+ ...
19+ ```
20+
21+ This formatting is handy because you can easily copy the branch and file
22+ directive for use with [ ` git-show ` ] ( viewing-a-file-on-another-branch.md ) .
23+
24+ See ` man git-grep ` for more details.
You can’t perform that action at this time.
0 commit comments