English 中文(简体)
为什么在名录中忽略所有档案,只有一份除外?
原标题:Why does git ignore all files in a directory except one?
  • 时间:2011-09-30 09:51:48
  •  标签:
  • git

I know there are many questions on how to ignore directories, and I usually haven t had any problem until now, but now I m stuck with something I don t understand.

我的名录结构如下:

/src
/war
  com.example.MyProject/
  WEB-INF/
    classes/
    deploy/
    lib/

我想忽略以下目录的内容:states/,deploy/com.example.Myproject/

*.log
war/WEB-INF/classes/
war/WEB-INF/deploy/
com.example.MyProject/

Files under com.example.MyProject/ are automatically generated, and git ignores all of them except for a file named com.example.MyProject.nocache.js. In fact, when I do git status I get:

# On branch myBranch
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#
#       modified:   .gitignore
#       ......
#       modified:   war/com.example.MyProject/com.example.MyProject.nocache.js

为什么该名录拒绝忽略该单一档案? 我做了什么错误?

最佳回答

如果档案已经由Gite跟踪,将档案添加到。 获胜 先从跟踪。 页: 1

问题回答

如果该档案已经添加到该指数中,即使你在<代码>.gitignore档案中添加该档案,该档案仍将留在该地。

要求将档案从盖特指数中删除:

git rm --cached war/com.example.MyProject/com.example.MyProject.nocache.js

<代码>-附后 备选办法确保文档留在您的夹中,并且从索引中删除。





相关问题
git confusion - cloning a repo is returning a past version

Im having some confusion with my git usage. I cloned a repo from one comp to the other, and the new clone is the state of the original that was active some time ago. So its cloning a past version. ...

Appropriate strategy for tagging and hotfixing with git

I was wondering if the strategy I m using for tagging and hotfixing tags (which then I use for deploying rails applications) with git is appropriate. For tagging I just tag a commit of the master ...

Tips on upgrading CVS to git/hg?

We still use CVS, I use git and hg for my personal use though I m still a novice at both, but I realize they re much more modern and better, faster, distributed, etc. It s just everyone is so ...

Using Git in a TFS shop

Using Git at home has spoiled me - I now find using TFS at work to be a bit of a drag and want to explore the possibility of using Git locally and syncing somehow with TFS. I figure there are a few ...

热门标签