Questions tagged [git-grep]

28 questions
12
votes
3 answers

Git Grep Multiple Words on Multiple Lines

I want to git grep the files which has two pre-specified words (if both exist, i.e. ANDing), assume these two words are word1 and word2 I tried git grep -e 'word1' --and -e 'word2' And also I tried git grep 'word1'.*'word2' but both retrieve the…
Ashraf Bashir
  • 9,686
  • 15
  • 57
  • 82
11
votes
3 answers

git blame of particular lines inside all files filtered with grep command

I know how to run gblame inside a file. I know how to grep a content inside all files in a directory. I'd like to see gblame of particular lines around that one that contains a content. Example: $ blame -R "content" ./ I see a list of files. I want…
sensorario
  • 20,262
  • 30
  • 97
  • 159
6
votes
2 answers

git grep

I'm trying to grep all line breaks after some binary operators in a project using git bash on a Windows machine. Tried the following commands which did not work: $ git grep "[+-*\|%]\ *\n" fatal: command line, '[+-*\|%]\ *\n': Invalid range end $…
AXO
  • 8,198
  • 6
  • 62
  • 63
3
votes
1 answer

Is there a way to execute git-grep command on a remote repository tree?

I would like to search the contents of files located in one of subtrees of the remote repository (origin/master). git-grep documentation says that command works on a current working tree. Consequently, how can I search through files that make up…
Marek Bocian
  • 115
  • 10
3
votes
0 answers

Hoogle Git repository

Is there a way to use type signature searches on not just the current working set, but the entire history of a project? The purpose would be to find and possibly recycle Haskell functions that were previously written and tested, but removed due to…
E Bro
  • 33
  • 5
3
votes
2 answers

Git Grep color options explained and/or compared

I'm trying to custom color my Git. After reading through the documentation, I've found my options I wanted to set. Everything was working fine except the Grep. I've realised, I haven't really used it in the past. I wanted to set colors for it with…
ppseprus
  • 538
  • 1
  • 8
  • 26
2
votes
1 answer

How to get `git grep` to show `git blame`-like information

I'd like to git grep in the usual way, but with something like the additional insight of git blame in the displayed results. In some instances I probably would benefit from including the metadata in the search query (show only results written by…
sh1
  • 4,324
  • 17
  • 30
2
votes
2 answers

Git log grep: How to match commit-message substrings regardless of word-order?

I tried this git log -i --all --grep='/(?=.*fix)(?=.*a)(?=.*bug)/' but did not work.
joydeba
  • 778
  • 1
  • 9
  • 24
2
votes
2 answers

git-grep not using multiple threads

I am trying to use git grep to search all revisions of a very large repository. The command I am using is: $ git rev-list --all | xargs git grep -I --threads 10 --line-number \ --only-matching "SomeString" I am using the latest official version…
Chris
  • 6,076
  • 11
  • 48
  • 62
2
votes
1 answer

How can I write a git alias that takes a string as an argument

I would like to write a git alias for: git log --all --grep='Big boi' What I have so far is: [alias] search = "!f() { str=${@}; echo $str; git log --all --grep=$str; }; f" Which echos the string perfectly fine but gives an error, I can't seem…
joshuatvernon
  • 1,530
  • 2
  • 23
  • 45
2
votes
2 answers

Finding files with both of two specified terms via git grep

I'm attempting to find files in my git repository using git grep and I have no easy way of doing so without manual searching. I have found one workaround like this: git grep -l 'term1' | xargs -i grep -l term2 {} But I'm wondering if there is a way…
JacobIRR
  • 8,545
  • 8
  • 39
  • 68
2
votes
1 answer

Turn off line wrapping when running git grep

Sometimes I do a git grep, and there's that one line which is so long it takes up half a page or more because of line wrapping. How can I tell git grep to turn of line wrapping, instead requiring me to scroll to the right if I want to see the rest…
Andrew Grimm
  • 78,473
  • 57
  • 200
  • 338
2
votes
2 answers

How do I see the commit sha when I use git grep?

I tried using git grep -i 'search' README.md and the output found some lines I was interested in looking at, but these lines did not print out the git sha's so that I could get more information about these commits. The output looked like…
Daniel Kaplan
  • 62,768
  • 50
  • 234
  • 356
2
votes
0 answers

Git grep url regex

I am trying to create bash script that checks my source code to flag absolutely url's as all of our devs should be using relative url's when it comes to internal links. I was thinking to create a bash script that could then be included as part of…
1
vote
1 answer

Git config edit color with multiple styles

does any of you know if there a way to apply git color with both bold and underline (or as a more general question - apply color with multiple style args)? I try to set git config color.grep.filename to be green, bold and underline... It seems as if…
Hacktivator
  • 63
  • 3
  • 7
1
2