如何忽略Git上的IDE设置? [英] How to ignore IDE settings on Git?

查看:153
本文介绍了如何忽略Git上的IDE设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下Git信息,我想忽略我的IDE(Eclipse)的设置。

I have below Git information and I would like to ignore settings of my IDE (Eclipse).

modified:   myproject/.classpath
modified:   myproject/.project
modified:   myproject/.settings/com.google.gdt.eclipse.core.prefs
modified:   myproject/.settings/org.eclipse.core.resources.prefs
modified:   myproject/.settings/org.eclipse.jdt.core.prefs
modified:   myproject/.settings/org.eclipse.wst.common.component
modified:   myproject/.settings/org.eclipse.wst.common.project.facet.core.xml
modified:   myproject/.settings/org.eclipse.wst.validation.prefs

我在我的 .gitignore 文件中尝试了以下语句,但它不起作用这些设置:

I tried the below statements in my .gitignore file, but it doesn't work for these settings:

.project
.classpath
.settings
*.project
*.classpath
*.settings
/.project
/.classpath
/.settings
.project/
.classpath/
.settings/
*.project/
*.classpath/
*.settings/

我正在使用Mac OS X,我还添加了全球gitignore文件这些设置 git config --global core.excludesfile'〜/ .gitignore',但是当我使用 git status 。我怎么了?

I am using Mac OS X and I also added global gitignore file with these settings git config --global core.excludesfile '~/.gitignore', but I'm still getting the above Git update messages when I check with git status. What am I wrong?

推荐答案

如果这些元素已经提交,您需要先删除它们:

If those elements were already committed, you need to remove them first:

git rm --cached .project
git rm --cached .classpath
git rm --cached -r .settings

- 缓存选项允许他们留下在工作树中,同时记录删除。

删除后,将被忽略。

The --cached option allows them to stay in the working tree, while being recorded for deletion.
Once deleted, they will be ignored.

一旦提交,下一次更改将被忽略

Once committed, the next changes will be ignored.

myproject / 文件夹中的简单 .gitignore 足够了:

A simple .gitignore in myproject/ folder is enough:

.project
.classpath
.settings/

请注意 / .setting 文件夹:将忽略其中的所有内容。

Note the / for .setting folder: that will ignore everything in it.

这篇关于如何忽略Git上的IDE设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆