Week 4"Grepping your life away"
A subtle twist on searching
As well as our git log tool, which we have used for searching, it is useful to know that there is actually another way to search for strings in your current directory.
We can use the git grep tool to find all files in our working tree which have a certain pattern in them.
john@satsuki:~/coderepo$ git grep awesome
newfile1:and some more awesome changes
newfile2:and a new awesome feature
john@satsuki:~/coderepo$
This has returned two files, both containing the string awesome , as this is the parameter that we passed to the git grep command.
We can extend this a little further and ask Git to supply the context around the line that it finds.
In our simple case, it results in the following.
john@satsuki:~/coderepo$ git grep -C3 awesome
newfile1-A new file
newfile1:and some more awesome changes
--
newfile2-Another new file
newfile2:and a new awesome feature
john@satsuki:~/coderepo$
This is just a short introduction to the git grep command.
If you want to know more you should spend some time reading the manual. |