2015-11-07 80 views
3

我想递归清除/重置目录中的所有git存储库。git别名清理/重置目录中的所有存储库

如果我执行下面的命令它按预期工作:

find . -name .git -type d -execdir sh -c "git clean -xdf" \; 

我有问题命令转换到一个Git别名:

xxx = "!f() { find . -name .git -type d -execdir sh -c "git clean -xdf" ; ; }; f; " 

我试图修正错误,如syntax error near unexpected token ;'`但是我正在一个没有成功的圈子里。

请帮我创建别名。 10X

回答

4

在这里你去:

xxx = "!f() { find . -name .git -type d -execdir git clean -xdf \\; ; }; f" 

有几件事情:

  • 没有必要sh -c包的命令,你可以直接使用它
  • 你一定要逃逸的\\;find命令的末尾,写为:\\;
+0

非常感谢! – mynkow