34 questions
1
vote
1
answer
106
views
Does `git diff` pass down its own arguments to sub-commands?
Summary / Question
Does git diff pass arguments provided to it down through to sub commands (e.g. git grep) when invoked? For example, when calling git diff -G with an additional flag of -i as well (e....
3
votes
1
answer
125
views
How to search string in all files in codebase, and list occurrences including the commit date
I'd like to
(1) search a git repo codebase files (not commit messages!) for a certain string,
and then (2) list all occurrences (filename only, but for each result),
but (3) also have those ...
1
vote
1
answer
171
views
How to check if there are banned words in a git repo
I would like to use git grep to check for banned strings in the repo.
if git grep --full-name --extended-regexp --line-number 'bad|words'
then
echo has bad words
else
echo does not have bad ...
0
votes
2
answers
92
views
Log a list of files and open them with vscode CLI (creating a Shell macro)
I'm trying to create a macro on my shell.
The operation I'm trying to automate is this one:
Find all the files containing TEXT_TO_SEARCH, and open them with VSCODE
I can do this with a one-liner
$ ...
4
votes
1
answer
594
views
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 ...
0
votes
2
answers
2k
views
How to `git grep` through a range of commits, all commits from the current commit back to the parent commit, or through all commits in entire repo
I'd like to be able to use git grep to do a regular expression search through:
the current commit
a given commit
a list of commits
a range of commits
a given commit all the way back to the parent ...
0
votes
0
answers
53
views
Can I combine git-archive with git-grep?
For a DevOps solution I'm looking for a way to combine git archive with git grep. Is it possible to combine this? e.g.:
git archive --remote=url.project.git HEAD: git grep -i searchString $(git ...
2
votes
2
answers
1k
views
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.
-2
votes
1
answer
287
views
git grep: Where is "binary file" in match?
I'm looking for something that may have been committed in a Git repository. I'm using a command like the following:
git grep ABCD `git rev-list --all`
and getting output like
Binary file ...
1
vote
1
answer
105
views
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 ...
0
votes
2
answers
838
views
How to use "git grep" to search for 8-bit encoded text in a files with the same encoding
I have a project where the files are 8-bit encoded (Win-1251).
Can you please tell me if there is a way using git grep to find a phrase composed of characters from the top of the ASCII table (i.e. ...
1
vote
1
answer
98
views
fatal: command line, '\/\/( ){0,}beforeEach\(async\(\(\) => \{$': Unmatched \{
I am looking for the list of files where some tests are commented like
// beforeEach(async(() => {
// beforeEach(async(() => {
// beforeEach(async(() => {
// beforeEach(async(()...
1
vote
2
answers
2k
views
git grepping on filenames
How can I pipe to git grep a list of files on which I want to search a specific pattern?
Specifically I do this:
git grep -l 'string to search'
and I want to do another git grep on the result ...
4
votes
1
answer
1k
views
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,...
2
votes
1
answer
1k
views
"git grep <pattern>" for just python (or any type of) files?
When I'm trying to find a pattern in a git-based project, I type:
git grep <pattern>
and git searches the entire project for that pattern. Sometimes this finds matches in non-source files, ...
3
votes
2
answers
851
views
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 "...
2
votes
1
answer
369
views
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 ...
25
votes
2
answers
26k
views
File names only using Git grep
I want to look only at distinct files which have a certain word in their text.
current_directory$ git grep 'word'
shows each line of the file which has a matching word.
So I tried this
...
-2
votes
1
answer
101
views
Find out when the last use of variable was removed from the git repo
I have an unused variable in my code, and I wonder how things got to be this way. Can I use git grep (or something else) to find out easily?
0
votes
2
answers
225
views
Searching Git for multiple hash's at one time
I just got a directive to revert a bunch of committed code. The good news is that all commit's have a reference string in them, something like:
ABC-1556
ABC-1616
ABC-4818
ABC-5919
This commend will ...
6
votes
1
answer
1k
views
How to order git grep results
I would like to order results returned by git grep using some git-related criteria, for example the commit date.
Is there a way to do that?
0
votes
1
answer
53
views
I want to skip pattern in comments between /* */ or whatever
I want to skip pattern in comments between /* */ or whatever.
for example f:
My name is
/*
alex
nice man
*/
alex is a nice man
Command:
git grep "alex" f
Print only:
alex is a nice man
I prefer use ...
0
votes
0
answers
482
views
How can I get rid of iine (end) in git grep and how do I use with exclude-standard?
I execute this command:
git grep -Ee "alex" -- bin
and I don't return to shell. In the end there is "line (end)".
How can I get rid of iine (end) without
git grep -Ee "alex" -- bin | more or kill ...
3
votes
0
answers
93
views
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 ...
2
votes
2
answers
1k
views
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 ...
7
votes
2
answers
12k
views
git grep <regex containing newline>
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: ...
1
vote
1
answer
487
views
helm-grep-do-git-grep searches in the current directory
helm-grep-do-git-grep with a prefix arg grep whole repo and without
grep only current dir.
I want it reversed
helm-grep-do-git-grep without a prefix arg grep whole repo and with
grep only ...
2
votes
1
answer
878
views
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 ...
4
votes
2
answers
2k
views
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 ...
2
votes
2
answers
1k
views
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 ...
16
votes
5
answers
7k
views
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
...
2
votes
0
answers
675
views
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 ...
1
vote
1
answer
1k
views
How to git grep in Sourcetree
How do I run git-grep in SourceTree?
I can see the ability to search commit messages, commit SHAs, branches, file changes, and users, under Workspace > Search, but not content within the workspace ...
13
votes
3
answers
5k
views
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:
$ ...