gitignore不会忽略文件夹 [英] gitignore does not ignore folder

查看:108
本文介绍了gitignore不会忽略文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目的根目录中,我有一个 foo 文件夹。在 foo 文件夹中,我有一个 bar 文件夹。我想忽略文件夹中所有文件的所有更改。我的 gitignore

  / foo / bar 

该文件夹被选中:它存在并且文件被忽略。 gitignore commit ted。但是,我有一个文件,在这里我进行了修改,并位于 bar 文件夹内。当我输入

  git status 

在我的 git bash 里面我看到了应该被忽略的文件。可能是什么原因,我怎么能成功地忽略我的酒吧文件夹中的所有文件?



请注意,这些文件以前被同一行忽略,但我必须暂时将该行删除到服务器上的 commit 某物。在 commit 之后,我将该行放回到 gitignore 中。这是前一阵子,但现在我已经观察到这些文件将在 git status 中。我希望能够修改忽略的文件,而不会出现在 git status 中。

解决方案

我猜这个文件夹已被检入git之前?尝试运行 git rm --cached< folder> 并再次检查。编辑:代码有一点它的错误。解决方案是:
git rm -r --cached< folder>
但是,这个答案让我找到了解决方案,所以我会接受它。



更新: -r 是必需的。


In the root of my project I have a foo folder. Inside the foo folder I have a bar folder. I would like to ignore all changes to all files inside my bar folder. I have this in my gitignore:

/foo/bar

The folder is checked: it exists and it has the files to be ignored. gitignore is committed. However, I have a file where I make a moification and is inside my bar folder. When I type

git status

inside my git bash I see the file which should have been ignored. What could be the reason and how can I successfully ignore all files inside my bar folder?

Note, that the files were previously ignored with the same line, but I had to temporarily remove that line to commit something on the server. After the commit, I put back the line into the gitignore. This was a while ago, but now I have observed that the files will be in git status. I would expect to be able to modify the ignored files without they appearing in the git status.

解决方案

I'm guessing this folder has been checked into git before? Try running git rm --cached <folder> and check again.

EDIT: The code had a little bug in it. The solution was: git rm -r --cached <folder> However, this answer has led me to the solution, so I will accept it.

UPDATE: The -r is required.

这篇关于gitignore不会忽略文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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