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
#
4

1 回答 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 文件,而不将其从目录中删除。

于 2013-10-11T17:02:59.980 回答