I often need to search for a particular string from a directory that has git directory .git/. This is the command I use:
find . -name .git -prune -o -print | xargs grep <string-to-search>
The -name .git -prune -o -print option is to ignore the files under .git/. However, it outputs a lot of 'Is a directory' messages that clutter the whole result. For example,
...
grep: ./reports: Is a directory
grep: ./scripts: Is a directory
grep: ./scripts/js: Is a directory
grep: ./scripts/js/adapter: Is a directory
...
How to modify the command line so that I can ignore the .git/ directory and all other directories (i.e. only search the searchable files).
Apparently, the -type f option doesn't work well in:
find -type f . -name .git -prune -o -print
git-grep?find . -type f -name .git -prune -o -print.find . -type f -name .git -prune -o -printactually still outputs directories.git-grep:git grep --untracked <string-to-search>. Let me keep this question open; I am still curious how we'd do this using the combination of grep and find.git-grep(or some other tool) handle this?