git gitignore 不会忽略我的 .settings/ 目录(由 eclipse 创建)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30460415/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
gitignore won't ignore my .settings/ directory (created by eclipse)
提问by Sean
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. I must be doing something real dumb.
我从来没有遇到过这么多麻烦.gitignore
,它通常可以正常工作。我一定在做一些真正愚蠢的事情。
NOTE: My .gitignore
file has more in it than just that one line (all the other lines works correctly).
注意:我的.gitignore
文件中包含的不仅仅是一行(所有其他行都正常工作)。
采纳答案by Chris Gerken
My .gitignore file has a leading forward slash before .settings:
我的 .gitignore 文件在 .settings 之前有一个前导正斜杠:
/.settings
where you don't have that slash. Try adding the slash
你没有那个斜线的地方。尝试添加斜线
回答by Matthew Kuraja
I thought I had the same problem. Turns out, the reason I kept seeing .settings/ in git statuswas because someone else already committed .settings/ to the repo. So, .settings/ kept showing up under the Changes not staged for commitfiles list because my IDE touched/changed this directory.
我以为我有同样的问题。事实证明,我一直在git status 中看到 .settings/ 的原因是因为其他人已经将 .settings/ 提交给了 repo。因此,.settings/ 一直显示在Changes not staged for commitfiles 列表下,因为我的 IDE 触及/更改了此目录。
You want .settings/ to stay invisible to git so remove it from tracking. 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. 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/ 对 git 不可见,因此将其从跟踪中删除。然后,当您进行涉及此目录的更改时,您将不会在 Untracked files 列表下看到它,因为您将它添加到 .gitignore 文件中。任何人首先提交 .settings/ 也不会认为它符合提交条件,因为他们使用您的更新更新了他们的 .gitignore 文件以忽略 .settings/ 文件夹。
回答by J. Chaney
/**/.settings/
/**/.settings/
worked to ignore the .settings folders below the root.
努力忽略根目录下的 .settings 文件夹。
回答by Sean
For me the fix was to move .settings/
to the end of the .gitignore
file. Initially I was just making it the first line of the .gitignore
file. Not sure why that matters. Does anyone have an explanation?
对我来说,修复是移到文件.settings/
的末尾.gitignore
。最初我只是把它作为.gitignore
文件的第一行。不知道为什么这很重要。有人有解释吗?