如何防止 .git 目录在重建期间被复制到 bin 目录? [英] How do I prevent .git directory from getting copied to bin directory during rebuild?

查看:30
本文介绍了如何防止 .git 目录在重建期间被复制到 bin 目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个 .git 目录不断重新出现在我的项目中,在我认为应该被忽略的目录中.每次我清理项目或在 Eclipse 中刷新它时,它都会重新出现.重复的 .git 目录会导致冗余文件阻止项目构建.

A .git directory keeps reappearing in my project, inside a directory that I think should be ignored. It reappears each time I clean the project or refresh it in Eclipse. The duplicated .git directory results in redundant files that prevent the project from building.

我在 Eclipse 中有一个 Android 项目,它链接来自 Java 项目的源代码,这是 LibGDX 处理项目的方式.我不想要的 .git 目录包含一个导致冲突的文件,所以我每次要构建到设备时都必须删除它.

I have an Android project in Eclipse that links source from a Java project, which is the way LibGDX handles a project. The .git directory that I don't want contains a file that causes a conflict, so I have to delete it every time I want to build to device.

它正在创建目录 MyProject/bin/classes/.git.但我的 .gitignore 文件中有 bin/.我的存储库在 MyProject 中.

It is creating the directory MyProject/bin/classes/.git. But I have bin/ in my .gitignore file. My repository is in MyProject.

冲突文件是 inclasses.gitCOMMIT_EDITMSG.这与我的链接源 Java 项目中的一个文件冲突:gen.gitCOMMIT_EDITMSG.也是同样的问题,因为我在该项目的 .gitignore 中有 gen.

The conflicting file is inclasses.gitCOMMIT_EDITMSG. This conflicts with a file in my linked source Java project: gen.gitCOMMIT_EDITMSG. Also the same issue, because I have gen in the .gitignore of that project.

我很确定 Eclipse 或 ADT 在重建或清理项目时会将 .git 目录复制到 bin 目录.

I am pretty sure either Eclipse or ADT that is copying the .git directory over to the bin directory when it rebuilds or cleans the project.

所以我现在的问题是,如何让 Eclipse 和/或 ADT 停止这样做?

So my question now is, how do I get Eclipse and/or ADT to stop doing that?

(如果您想查看我的旧 .gitignore,我认为这无关紧要,因为它已正确设置为忽略 bin 目录,您可以单击已编辑"链接在这篇文章的历史记录中查看它.)

推荐答案

如果您想要排除 *.git 文件以在 eclipse 中构建期间复制,您可以在该特定项目的 Java Build Path 菜单下进行设置,然后将 *.git 添加到排除模式中.这里非常棘手,因为您可以指定包含模式或排除模式,但不能同时指定两者.因此,也许您想尝试排除 *.git 以便它在构建期间不会复制.

If what you want is to exclude *.git file to be copied during the build in eclipse, you can set this under Java Build Path menu for that specific project, and then add *.git into the exclusion patterns. It is quite tricky here because you can either specify inclusion patterns, or exclusion patterns, but not both of them. So, maybe you want to try to exclude *.git so that it does not copy during build.

例如看下面的截图:

这篇关于如何防止 .git 目录在重建期间被复制到 bin 目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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