git是否支持路径中的通配符? [英] Does git support wildcards in paths?

查看:947
本文介绍了git是否支持路径中的通配符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



基本上,我希望能够做到这一点:

p>

  git reset  -  * .exe 



  git reset  -  * / some_executable.exe 



不是这样:

$ $ p $ g $ git重置 - some / very / long / path / some_executable.exe

能够做到这一点:

  git reset  -  topleveldirectory / another /子目录/ * 

而不是:

  git reset -  topleveldirectory / another / subdirectory / SomeFile.cpp 
git reset --topleveldirectory / another / subdirectory / SomFile.h



think 我可以在git-add中使用通配符 * 来添加文件,但是没有找到任何适用于上述情况。



任何建议使用:在64位Windows 7上使用git version 1.7.3.1.msysgit.0

$ b使用:git version 1.7.3.1.msysgit.0在64位Windows 7上使用



$ b

解决方案

Git确实支持一些pathpec globbing,但是您需要小心shell转义字符,以免它们在您的情况下被解释,msys bash,它不支持更复杂的通配符扩展。

编辑:另外,对于您的重置示例,您可以将目录作为参数传递给git reset和git将以递归方式操作。

  git reset my / long / path 

而不是

  git reset my / long / path / * 


I have looked, searched, and read documentation and can't really find anything about this.

Basically, I want to be able to do this:

git reset -- *.exe

or

git reset -- */some_executable.exe

Instead of this:

git reset -- some/very/long/path/some_executable.exe

Also it'd be nice to be able to do this:

git reset -- topleveldirectory/another/subdirectory/*

Instead of this:

git reset -- topleveldirectory/another/subdirectory/SomeFile.cpp
git reset -- topleveldirectory/another/subdirectory/SomFile.h

I think I can use the wildcard * in git-add to add files, but haven't found anything that works in the case above.

Any suggestions or pointers to where I can look for more info?

Using: git version 1.7.3.1.msysgit.0 on 64-bit Windows 7

解决方案

Git does support some pathspec globbing, but you need to be careful to shell-escape the characters so they aren't interpreted by in your case, msys bash, which doesn't support more sophisticated wildcard expansion.

EDIT: Also, for your reset example, you can just pass the directory as an argument to git reset and git will operate recursively.

git reset my/long/path

rather than

git reset my/long/path/*

这篇关于git是否支持路径中的通配符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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