Reputation: 11768
I would like to grep inside Untracked files
and in files from Changes not staged for commit
but not in the rest.
Is it possible to achieve this with git grep
?
Upvotes: 4
Views: 1982
Reputation: 465
To list untracked files try:
git ls-files --others --exclude-standard
To grep in untracked files.
grep 'search' $(git ls-files -m --others --exclude-standard)
replace the search word with your search string.
From man-page:
git-ls-files - Show information about files in the index and the working tree
-m, --modified
Show modified files in the output
-o, --others
Show other (i.e. untracked) files in the output
--exclude-standard
Add the standard git exclusions: .git/info/exclude, .gitignore in each directory, and the user’s global exclusion file.
Credits goes to
Upvotes: 4