简体   繁体   English

忽略Git中的文件

[英]Ignoring file in Git

We have a java repository which is handled through IntelliJ IDE. 我们有一个通过IntelliJ IDE处理的Java存储库。 We have added a .gitignore file to the root of the repo, containing the following lines among other ones: 我们在.gitignore的根目录中添加了一个.gitignore文件,其中包括以下几行:

.iml
*/*iml

However, after cloning the repo and opening it with IntelliJ, it generates a new file my.project.package.iml which is not ignored by Git, it considers it as an untracked file. 但是,克隆存储库并使用IntelliJ打开它之后,它将生成一个新文件my.project.package.iml ,Git不会忽略该文件,它将其视为未跟踪的文件。

I've also tried to ignore it through git update-index --assume-unchanged my.project.package.iml , but it doesn't take any effect. 我也尝试通过git update-index --assume-unchanged my.project.package.iml忽略它,但是它没有任何效果。 I've tried removing the file and regenerating it after applying this command, with no effect either. 我尝试删除该文件并在应用此命令后重新生成它,也没有任何效果。

Could someone explain my what's happening here? 有人可以解释我在这里发生的事情吗?

EDIT 编辑

It seems that the issue with .gitignore file was that you should put *.iml instead of just .iml . 似乎.gitignore文件的问题是您应该放置*.iml而不是.iml But what happens with git update-index --assume-unchanged command? 但是git update-index --assume-unchanged命令会发生什么? Why is it not taking any effect? 为什么不起作用? I'm really curious about that... 我真的很好奇...

Try to change .gitignore file as the following: 尝试更改.gitignore文件,如下所示:

*.iml */*iml

eg add asterisk to the first row. 例如,在第一行添加星号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM