Quick Tip: Grep in Git
Learn about two features in Git that will make your life way easier by simplifying searching: git-grep and git-log grep.
Join the DZone community and get the full member experience.Join For Free
this quick tip is about two small features of git i wish i had known about earlier as it makes it way easier to do searching through it.
is a way to search through your tracked files for whatever you provide. for example, if we want all files with the word index in it:
git grep index
we can limit to specific files, for example, if we want to filter the above example to just json files:
git grep index -- '*.json'
we can search for multiple items in a single file, for example, if we want to find all files with index and model in it:
git grep --all-match -e index -e model
git-log has a grep function too
which is awesome for finding commit messages with a specific word or words in it. for example, if i want to find all commits about speakers for devconf i could do:
git log --all --grep "speaker"
Published at DZone with permission of Robert Maclean, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.