简体   繁体   English

Egit:将gitignore设置为忽略所有Eclipse项目文件

[英]Egit: Set gitignore to ignore all eclipse project files

I have a project up on github and I want to remove all eclipse related files from it and allow people who clone it to use any ide they want. 我在github上有一个项目,我想从中删除所有与Eclipse相关的文件,并允许克隆它的人使用他们想要的任何想法。 Here is the project: https://github.com/vedi0boy/Archipelo 这是项目: https : //github.com/vedi0boy/Archipelo

What would I have to put in my gitignore? 我必须在gitignore中放入什么? I'm still very new to the whole version control manager thing so you don't have to tell me exactly what to put but maybe explain how it works and what to be careful about so that it will still work. 对于整个版本控制管理器我还是很陌生,因此您不必确切地告诉我要放什么,而可以解释它是如何工作的以及需要注意什么以便它仍然可以工作。

By the way, it uses gradle so I would also like it so that the gradle related files remain untouched since cloners will need them to build the project and I plan to remove 'APIs' folder and just use gradle dependencies. 顺便说一句,它使用gradle,所以我也希望它保持不变,因为克隆程序将需要它们来构建项目,而我计划删除“ API”文件夹,而仅使用gradle依赖项。

For excluding configuration files you have to configure .gitignore to something as follows: 要排除配置文件,您必须将.gitignore配置为以下内容:

# Eclipse
.classpath
.project
.settings/

# Intellij
.idea/
*.iml
*.iws

# Mac
.DS_Store

# Maven
log/
target/

And, only after this, you have to push your project because now you have to push your configuration to the remote repo. 而且,仅在此之后,您才需要推送项目,因为现在您必须将配置推送到远程仓库。

And you can not delete it locally and push. 而且您不能在本地删除它并进行推送。 You have to delete it from remote repo only: 您只需要从远程仓库中删除它:

git rm --cached .project git rm-缓存的.project

For a directory: 对于目录:

git rm --cached -r target git rm --cached -r目标

One of my .gitignore files looks like this: 我的.gitignore文件之一如下所示:

/bin
/.classpath
/.project
/.settings
/target

You can look at other projects at eg GitHub to let you inspire what you might want to put into your .gitignore , eg: 您可以在GitHub上查看其他项目,以激发您可能想要放入.gitignore ,例如:

However, I think my example above should be sufficient to start with. 但是,我认为上面的例子应该足够了。

Add all the eclipse files to the .gitignore and, to remove them from the remote repository, you will have to 将所有eclipse文件添加到.gitignore,然后将其从远程存储库中删除,

git rm (-r) --cached eclipseProjectFile

The above command will remove the file from the repo, but not from your machine. 上面的命令将从存储库中删除文件,但不会从您的计算机中删除文件。

1 - create .gitignore file on your GIT project root direcotry (where you have typed "git init" (near .git directory) ). 1-在GIT项目根目录(在其中键入“ git init”(。git目录附近))上创建.gitignore文件。 With content of nazar_art noticed or you can add some other pattern for ignore. 注意到nazar_art的内容,或者您​​可以添加其他忽略模式。

2 - git rm -r --cached file_1 file_n directory_1 directory_n ... 2- git rm -r --cached file_1 file_n directory_1 directory_n ...

3 - git commit -m "removed some files and directories from remote repo and created gitignore :))" 3- git commit -m "removed some files and directories from remote repo and created gitignore :))"

4 - git push -u origin --all (this will synch all branch of your remote (origin) repo) or you can type git push [remote] [branch] 4- git push -u origin --all (这将同步远程(原始)存储库的所有分支),也可以键入git push [remote] [branch]

i know it is late. 我知道已经晚了。 but may be helpful somebody who just beginning 但对刚开始的人可能会有所帮助

This is general answer to ignore any file extension from git staging. 这是忽略git暂存中任何文件扩展名的一般答案。 1. In Eclispe go to windows->preferences->git-> ignore resources (you can simply search "ignore resources"). 1.在Eclispe中,转到Windows-> preferences-> git->忽略资源(您可以简单地搜索“忽略资源”)。 2. check any class extension that you want to avoid staging in git staging area. 2.检查要避免在git暂存区中暂存的任何类扩展。 3. if you do not find your extension there, you have option to add any extension that you need to ignore. 3.如果在那里找不到扩展名,则可以选择添加任何需要忽略的扩展名。

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

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