User Tools

Site Tools


git_searching

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
git_searching [2019/02/21 13:46]
rpjday [Searching with git log]
git_searching [2019/02/21 14:17] (current)
rpjday [Config options]
Line 19: Line 19:
 $ git log --author="​P\. J\." $ git log --author="​P\. J\."
 $ git log --author="​Robert P. J. Day" --oneline $ git log --author="​Robert P. J. Day" --oneline
 +$ git log --author="​Robert P. J. Day" --oneline | wc -l
 +104
 $ git log -i --author="​robert p. j. day" $ git log -i --author="​robert p. j. day"
 </​code>​ </​code>​
Line 37: Line 39:
 $ git log --since="​Feb 1, 2019" $ git log --since="​Feb 1, 2019"
 $ git log --author="​Ben Straub"​ --since="​Jan 1, 2019" --until="​Feb 1, 2019" $ git log --author="​Ben Straub"​ --since="​Jan 1, 2019" --until="​Feb 1, 2019"
 +</​code>​
 +
 +==== Using the "​--grep"​ option ====
 +
 +<​code>​
 +--grep=<​pattern>​
 +    Limit the commits output to ones with log message that
 +    matches the specified pattern (regular expression). With
 +    more than one --grep=<​pattern>,​ commits whose message
 +    matches any of the given patterns are chosen (but see
 +    --all-match).
 +
 +...
 +
 +--all-match
 +    Limit the commits output to ones that match all given
 +    --grep, instead of ones that match at least one.
 +
 +--invert-grep
 +    Limit the commits output to ones with log message that do
 +    not match the pattern specified with --grep=<​pattern>​.
 +</​code>​
 +
 +Ignoring case:
 +
 +<​code>​
 +$ git log --grep="​Tagging"​ --oneline | wc -l
 +6
 +$ git log --grep="​tagging"​ --oneline | wc -l
 +9
 +$ git log -i --grep="​tagging"​ --oneline | wc -l
 +13
 +$
 +</​code>​
 +
 +Specifying AND or OR:
 +
 +<​code>​
 +$ git log -i --grep="​tagging"​ --grep="​rewording"​ --oneline | wc -l
 +66
 +$ git log -i --grep="​tagging"​ --grep="​rewording"​ --all-match --oneline | wc -l
 +2
 +$ git log -i --grep="​tagging"​ --grep="​rewording"​ --all-match ​
 +commit 110e27b003c10b4574ee49a47a090e125d6c4811
 +Merge: 72d6a54 a402fcf
 +Author: Ben Straub <​ben@straub.cc>​
 +Date:   Mon Oct 16 10:30:02 2017 -0700
 +
 +    Merge pull request #866 from rpjday/​tagging
 +    ​
 +    Add TIP to tagging section explaining "​-l";​ also some rewording
 +
 +commit a402fcf53fb0d8d0c165ca9ee9ce233ea955cb85
 +Author: Robert P. J. Day <​rpjday@crashcourse.ca>​
 +Date:   Mon Oct 16 01:44:21 2017 -0700
 +
 +    Add TIP to tagging section explaining "​-l";​ also some rewording
 +    ​
 +      - Clarify the need for [-l|--llist]
 +      - Some minor rewording
 +$
 +</​code>​
 +
 +==== Ignoring merge commits with "​--no-merges"​ ====
 +
 +In many cases, merge commits are of no interest since they simply merge commits that produce actual change.
 +
 +<​code>​
 +$ git log --author="​Ben Straub"​ --oneline | wc -l
 +803
 +$ git log --author="​Ben Straub"​ --oneline --no-merges | wc -l
 +300
 +$
 +</​code>​
 +
 +===== Searching with "git grep" =====
 +
 +==== DESCRIPTION ====
 +
 +<​code>​
 +Look for specified patterns in the tracked files in the work
 +tree, blobs registered in the index file, or blobs in given
 +tree objects. Patterns are lists of one or more search
 +expressions separated by newline characters. An empty string as
 +search expression matches all lines.
 +</​code>​
 +
 +==== SYNOPSIS ====
 +
 +Options:
 +
 +<​code>​
 +[-a | --text] [-I] [--textconv] [-i | --ignore-case] [-w | --word-regexp]
 +  [-v | --invert-match] [-h|-H] [--full-name]
 +  [-E | --extended-regexp] [-G | --basic-regexp]
 +  [-P | --perl-regexp]
 +  [-F | --fixed-strings] [-n | --line-number] [--column]
 +  [-l | --files-with-matches] [-L | --files-without-match]
 +  [(-O | --open-files-in-pager) [<​pager>​]]
 +  [-z | --null]
 +  [ -o | --only-matching ] [-c | --count] [--all-match] [-q | --quiet]
 +  [--max-depth <​depth>​] [--[no-]recursive]
 +  [--color[=<​when>​] | --no-color]
 +  [--break] [--heading] [-p | --show-function]
 +  [-A <​post-context>​] [-B <​pre-context>​] [-C <​context>​]
 +  [-W | --function-context]
 +  [--threads <​num>​]
 +  [-f <​file>​] [-e] <​pattern>​
 +  [--and|--or|--not|(|)|-e <​pattern>​...]
 +  [-recurse-submodules] [--parent-basename <​basename>​]
 +  [ [--[no-]exclude-standard] [--cached | --no-index | --untracked] | tree>​...]
 +  [--] [<​pathspec>​...]
 +</​code>​
 +
 +==== Config options ====
 +
 +  * ''​grep.lineNumber''​
 +  * ''​grep.patternType''​
 +  * ''​grep.extendedRegexp''​
 +  * ''​grep.threads''​
 +  * ''​grep.fullName''​
 +  * ''​grep.fallbackToNoIndex''​
 +
 +See ''​man git-config''​.
 +
 +==== Examples ====
 +
 +<​code>​
 +$ git grep -il torvalds ​
 +book/​01-introduction/​sections/​history.asc
 +book/​07-git-tools/​sections/​debugging.asc
 +$
 </​code>​ </​code>​
git_searching.1550756797.txt.gz ยท Last modified: 2019/02/21 13:46 by rpjday