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 similar to this which doesn't require xargs:
git grep -l -E 'term1|term2'
This essentially means show me the files containing either term1 or terms2... is there a "show me files with BOTH these terms."
I'm trying to use the git grep command in a way that is not practical for piping commands into other commands. I really hate working with python's subprocess module and its use of piping...
Two ways to achieve the goal:
1) combining multiple patterns specified by
-eoption with--andflag2) using
--all-matchflaghttps://git-scm.com/docs/git-grep#git-grep--e