"混帐新增]使用通配符不能正常工作,因为我希望 - 我必须光盘放入特定目录? [英] "git add" using wildcard is not functioning as I hoped - must I cd into specific directories?

查看:173
本文介绍了"混帐新增]使用通配符不能正常工作,因为我希望 - 我必须光盘放入特定目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试做一个基本的 git的添加* .erb (或任何简单的通配符前pressions)Git是不承认它(它们)。作为一个侧面说明,我以前从来没有这样做过,我相信这是一个新手的错误,但我发现没有任何帮助其他SO职位或我校的校友群发功能,所以我想这个职位可能是合适的。

When I try to do a basic git add *.erb (or any simple wildcard expressions) git is not recognizing it (them). As a side-note, I have never done this before so I'm sure it's a rookie mistake, but I've found no help in other SO posts or my school's alumni listserv so I thought this post may be appropriate.

有关(不同的)例如, git的状态是给我:

For (a different) example, git status is giving me:

#   modified:   config/routes.rb
#   modified:   spec/models/question_spec.rb

我想只是阶段性的路由文件,所以我试图 git的添加* s.rb 并没有骰子。我在应用程序的根......我需要在包含该文件(S)我试图通配符前pression适用于该目录?这将是痛苦的,但...其实...它只是工作。

I wanted to only stage the routes file, so I tried git add *s.rb and no dice. I am in the root of the app...do I need to be in the directory that contains the file(s) I'm trying to apply the wildcard expression to? That would be painful, but...actually...it just worked.

希望这并不一定是一个单独的职务,但有使用通配符,你不必cd到特定的目录更简单的方法?

Hope this doesn't have to be a separate post, but is there an easier way to use wildcards where you don't have to cd into the specific directory?

推荐答案

把它周围的单引号。这应该工作。

Put it around single quotes. This should work.

git的加'* s.rb

更新

更多的测试后,我发现,我甚至可以做 git的添加* s.rb 不带引号。这可能只是对我的工作和我的Git版本1.7.10.4(Mac OSX上的狮子,自制)。我的解释是,如果shell通配符扩展不匹配任何文件,它会提供原始未展开论证* s.rb来 git的添加

After more testing, I find out that I can even do git add *s.rb without quotes. This might just work for me with my git version 1.7.10.4 (Mac OSX Lion, homebrew). My explanation is that if shell wildcards expansion doesn't match any file, it'd supply the original unexpanded argument '*s.rb' to git add.

sh-3.2$ git status
#
#   modified:   config/routes.rb
#   modified:   spec/models/products_spec.rb
#

现在我 git的添加不带引号。

sh-3.2$ git add *s.rb

令人惊讶它的作品!

Surprisingly it works!

sh-3.2$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   modified:   config/routes.rb
#
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   spec/models/products_spec.rb
#

如果通配符模式不匹配的任何文件,git会给出这个错误。

If wildcard pattern doesn't match any file, git will give out this error.

sh-3.2$ git add *x.rb
fatal: pathspec '*x.rb' did not match any files

这篇关于&QUOT;混帐新增]使用通配符不能正常工作,因为我希望 - 我必须光盘放入特定目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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