当忽略文件存在时,如何用通配符进行git-add? [英] How do I git-add with wildcards when ignored files are present?

查看:865
本文介绍了当忽略文件存在时,如何用通配符进行git-add?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows 7 x64上使用msysgit。我无法弄清楚如何告诉Git在有一些.gitignore可能会忽略的文件时添加大量文件。例如:
$ b $ ol <

  • 初始化一个git仓库。

  • 用内容创建一个.gitignore :

      *。foo 


  • 创建文件test.txt和test.foo。


  • 尝试 git add



  • 当我尝试这个时,git抱怨test.foo被忽略,如果我真的想添加它,我应该使用-f。我宁愿做的是添加所有配置为忽略的文件,但。我看着git-add文档,它看起来像-A应该帮助;帮助说:...并添加所有未被.gitignore机制忽略的未跟踪文件。没有骰子,当我尝试 git add -A 我得到相同的错误。使用-f添加忽略的文件,这不是我想要的。 (这个用例是在忽略.suo和其他文件之后,从VS项目中大量添加文件)。

    这是我使用的git实现的问题,或者是否有一些参数git-add我缺少?

    解决方案

    这里 git add * 抱怨,但是 git add。会做什么(1.7.0.4,Linux)。

    < git add(1)


    git add命令将会默认情况下不会添加
    忽略的文件。如果任何
    忽略的文件在命令行中明确指定
    ,那么git add
    将会失败并显示一个被忽略的
    文件的列表。被
    目录递归的文件被忽略或者文件名
    由Git执行的globbing(在shell之前引用你的
    球体)将被
    默默忽略。



    I'm using msysgit on Windows 7 x64. I can't figure out how to tell Git to add a lot of files when there are some files that .gitignore might ignore. For example:

    1. Initialize a git repository.
    2. Create a .gitignore with contents:

      *.foo
      

    3. Create files "test.txt" and "test.foo".

    4. Try git add .

    When I try this, git complains that test.foo is ignored and I should use -f if I really want to add it. What I'd rather do is add everything but the files that are configured to be ignored. I looked at the git-add documentation and it looks like -A should help; help says, "... and add all untracked files that are not ignored by .gitignore mechanism." No dice, when I try git add -A . I get the same error. Using -f adds the ignored file, which is not what I want. (The use case is mass-adding files from a VS project after ignoring .suo and other files.)

    Is this a problem with the git implementation I'm using, or is there some argument to git-add that I am missing?

    解决方案

    Here git add * complains, but git add . does what is expected (1.7.0.4, Linux).

    From git-add(1):

    The git add command will not add ignored files by default. If any ignored files were explicitly specified on the command line, git add will fail with a list of ignored files. Ignored files reached by directory recursion or filename globbing performed by Git (quote your globs before the shell) will be silently ignored.

    这篇关于当忽略文件存在时,如何用通配符进行git-add?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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