简体   繁体   English

gitignore不会忽略我的.settings /目录(由eclipse创建)

[英]gitignore won't ignore my .settings/ directory (created by eclipse)

git status: git状态:

Untracked files:
(use "git add <file>..." to include in what will be committed)
    .settings/

I've tried the following variations on my .gitignore file and nothing seems to work: 我在.gitignore文件上尝试了以下变体,但似乎没有任何效果:

.settings/

*settings*

*.settings/

.settings/*

I've never had this much trouble with .gitignore , it usually just works. 我从来没有遇到过.gitignore这样的麻烦,它通常可以正常工作。 I must be doing something real dumb. 我一定在做些愚蠢的事。

NOTE: My .gitignore file has more in it than just that one line (all the other lines works correctly). 注意:我的.gitignore文件中包含的内容不只一行(其他所有行均正常工作)。

I thought I had the same problem. 我以为我有同样的问题。 Turns out, the reason I kept seeing .settings/ in git status was because someone else already committed .settings/ to the repo. 原来,我一直在git状态下看到.settings /的原因是因为其他人已经将.settings /提交到了仓库。 So, .settings/ kept showing up under the Changes not staged for commit files list because my IDE touched/changed this directory. 因此,.settings /一直显示在“ 未暂缓提交文件的更改”列表下,因为我的IDE触摸/更改了该目录。

You want .settings/ to stay invisible to git so remove it from tracking. 您希望.settings /对git保持不可见,因此将其从跟踪中删除。 Then, when you make a change that touches this directory, you won't see it under the Untracked files list because you added it to the .gitignore file. 然后,当您进行触摸此目录的更改时,您将不会在“未跟踪的文件”列表下看到它,因为您已将其添加到.gitignore文件中。 Whoever committed .settings/ in the 1st place also won't see it as eligible for commit either because they updated their .gitignore file with your update to ignore .settings/ folder. 谁在第一位置提交.settings /,也不会认为它符合提交条件,因为他们用您的更新更新了.gitignore文件,以忽略.settings /文件夹。

/**/.settings/ /**/.settings/

worked to ignore the .settings folders below the root. 试图忽略根目录下的.settings文件夹。

My .gitignore file has a leading forward slash before .settings: 我的.gitignore文件在.settings之前有一个正斜杠:

/.settings

where you don't have that slash. 没有斜线的地方 Try adding the slash 尝试添加斜线

For me the fix was to move .settings/ to the end of the .gitignore file. 对我来说,解决方法是将.settings/移动到.gitignore文件的末尾。 Initially I was just making it the first line of the .gitignore file. 最初,我只是将其设置为.gitignore文件的第一行。 Not sure why that matters. 不知道为什么这很重要。 Does anyone have an explanation? 有人有解释吗?

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

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