如何gp grep的主要存储库及其所有子模块? [英] How to git grep the main repository and all its submodules?

查看:105
本文介绍了如何gp grep的主要存储库及其所有子模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在博客上找到了这个项目和子模块:

  [别名] 
sgrep =! f(){git grep \$ 1 \; git submodule foreach \git grep'$ 1'; true \| grep -B 1 \$ 1 \;}; f

我更新了我的〜/ .gitconfig 以包含它,但是当我使用别名时,它说:

fatal:bad config file line 9 in /home/myname/.gitconfig



我做错了什么?

解决方案

一般来说,类似于 GitConfig:不好的配置为shell命令,这可能是因为' \ '字符在被shell执行之前被git首先解释。



但在你的情况下,由于周围的双引号,这应该可以正常工作。

它在Ubuntu上的git 1.8.4上工作。 / p>

因此,简化您的 .gitconfig ,并检查它是否更好,如果它包含您的别名( )else。

如果这确实起作用,那么问题就出现在配置文件的其他地方。


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

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

I updated my ~/.gitconfig to include it, but when I use the alias, it says:

fatal: bad config file line 9 in /home/myname/.gitconfig

What am I doing wrong?

解决方案

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.

这篇关于如何gp grep的主要存储库及其所有子模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆