git/list[1] front-page[2] threads[3] people[4] search[5] about
 

git grep: search whole tree by default?

From
Piotr Krukowiecki <piotr.krukowiecki@gmail.com>
Date
Oct 23, 2013, 08:25 UTC
Message-ID
<CAA01CsqgNKdDAc9OL9zdk=3tnK9GAG=6w+wP_XSoiefBOgfzRQ@mail.gmail.com>
Hi,

it would be nice if grep searched not only in current directory and subdirectories, but in whole tree.

I know I can use ":/" as a pathspec, but since most git commands work tree, I got used to this and forgot that grep is different.

It's easy to make a mistake and believe that your code does not contain searched string XXX - because you have searched from a subdirectory, not from the top level of your working tree. OTOH, if grep searches whole tree, you'll notice you get results from outside of CWD and if you don't want that, you will be able to limit the search to '.'

I think there were discussion about how there are several git commands which do not search in whole tree by default and that it's going to be changed. I think "add" is one of such commands. Is 'grep' left unchanged?

Last discussion I found is from 2011 March (http://thread.gmane.org/gmane.comp.version-control.git/168063/focus=168188) and it says it's not going to be changed :(

-- 
Piotr Krukowiecki
Next: Matthieu Moy
Message 1 of 14 in “git grep: search whole tree by default?”
  1. Piotr KrukowieckiOct 23, 2013
  2. Matthieu MoyOct 23, 2013
  3. Junio C HamanoOct 23, 2013
  4. Jed BrownOct 23, 2013
  5. Junio C HamanoOct 23, 2013
  6. Jed BrownOct 23, 2013
  7. Junio C HamanoOct 23, 2013
  8. David AguilarOct 24, 2013
  9. Matthieu MoyOct 23, 2013
  10. Jeff KingOct 24, 2013
  11. Junio C HamanoOct 24, 2013
  12. David AguilarOct 25, 2013
  13. Jeff KingOct 25, 2013
  14. Duy NguyenOct 25, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.