How to git grep the main repository and all its submodules?

前端 未结 2 1011
Happy的楠姐
Happy的楠姐 2020-12-19 04:40

I found this at a blog to grep project and submodules:

[alias]
  sgrep = \"!f() { git grep \\\"$1\\\"; git submodule foreach \\\"git grep \'$1\'; true\\\" |          


        
2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-19 05:34

    Generally, similar to "GitConfig: bad config for shell command", it may be because the '\' character is interpreted by git first, before being executed in a shell.

    But in your case, this should work as expected because of the surrounding double-quotes.
    It does work on my git 1.8.4 on Ubuntu.

    So simplify your .gitconfig and check if works better if it contains your alias (and nothing) else.
    If that does work, then the issue is elsewhere in your config file.

提交回复
热议问题