Git忽略文件,即使有gitignore文件

3

所以,我已经设置了我的全局.gitignore文件来忽略所有以.iml结尾的文件。然而,出于某种原因,它没有忽略一个特定的iml文件。我已经设置了忽略文件和

~/projects/dhub
calebsutton$cat /home/calebsutton/.gitignore
*.iml

~/projects/dhub
calebsutton$git status
# On branch DM-481
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   new file:   app/web/src/main/java/com/wellcentive/integration/page/sourcetype/SourceTypeActionPage.java
#   new file:   app/web/src/main/java/com/wellcentive/integration/page/sourcetype/SourceTypeListPage.java
#   new file:   app/web/src/main/java/com/wellcentive/integration/page/sourcetype/grid/SourceTypeListGrid.java
#
# 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:   app/web/src/main/java/com/wellcentive/integration/page/sourcetype/grid/SourceTypeListGrid.java
#   modified:   app/web/web.iml
#
1个回答

7
运行以下命令: git ls-files --others | grep web.iml 以查找未被跟踪的文件列表中是否有该特定文件。如果它不在列表中,则需要取消跟踪它。 (感谢jthill)
git ls-files -ic --exclude-standard

同时也可以执行第一个命令所做的内容。

在此运行:

git rm --cached app/web/web.iml

这将从您的跟踪文件列表中删除web.iml文件,而不会将其从目录中删除。


2
列出可能错误追踪的文件的更直接的方法是 git ls-files -ic --exclude-standard - jthill

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接