android - Eclipse:将一个项目添加到另一个项目的构建路径时如何忽略.git subdir?

标签 android eclipse git

我正在开发一个应该在 Android 和常规 Java SE 上运行的应用程序。

我有一个名为foobar-core 的eclipse 项目,其中包含Android 和SE 版本都使用的代码。我有另一个名为 foobar-android 的项目,其中包含所有特定于 android 的代码。

我需要引用foobar-android项目中的一些foobar-core代码,所以我将foobar-core添加到< strong>foobar-android 在 Settings -> Java Build path -> Projects -> Required projects on the build path.这很好用,因为我现在可以在 foobar-android 中使用来自 foobare-core 的代码。

问题来了:foobar-corefoobar-android 都是独立的 git 存储库,这意味着它们都有一个 .git 子目录。现在,每当我编译 foobar-android 时,“控制台”选项卡上都会收到很多警告。它们看起来像这样:

/foobar-core/src/.git/HEAD conflicts with another file already put at .git/HEAD
/foobar-core/src/.git/config conflicts with another file already put at .git/config
/foobar-core/src/.git/description conflicts with another file already put at > .git/description
/foobar-core/src/.git/hooks/applypatch-msg.sample conflicts with another file already > put at .git/hooks/applypatch-msg.sample

从 foobar-core 项目导入源代码时,如何让 Eclipse 忽略 .git 文件?

最佳答案

即使您只有一个 git 存储库,也最好忽略 .git 目录,因为其他 Eclipse 会浪费大量时间查看其中的文件,即使它从不需要对它们做任何事情。特别是,当您进行项目范围的搜索时,Eclipse 将搜索 .git 目录中的所有文件,这会花费很长时间并最终向您显示大量重复项(或几乎重复项,同一文件的旧版本找到相同的搜索词)。

我认为 Eclipse git 扩展可能会解决这个问题,但如果您不想安装另一个扩展,我发现最好的方法是告诉 Eclipse 所有 .git 目录都是“派生的”,这似乎让 Eclipse 在某种程度上忽略包含的文件。

您可以通过从 Package Explorer View 切换到 Navigator View 来执行此操作,您应该会在其中看到 .git 文件夹。右键单击 .git 文件夹,选择属性,从设置选择器中选择资源,然后选中“派生”框。

关于android - Eclipse:将一个项目添加到另一个项目的构建路径时如何忽略.git subdir?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3176260/

相关文章:

android - 如果我们在 override 函数中的 super() 函数之前或之后编写代码会产生什么影响

android - 如何触发fragment的onCreate方法?

android - 将数据从 Activity 传递到 fragment (空 getArguments() )

git - 看不到远程分支

git - 在 Git 中将多个提交 merge 为一个

git - 尝试更改 github 页面的源时无法选择 master 分支/docs 文件夹

java - Android获取当前UTC时间

python - 如何在 Eclipse 中运行 django 测试以使调试成为可能,但在测试数据库上

java - 如何传输用 Eclipse 编写的项目?

java - Array.sort 只返回 0 个值。数组大小正确并且数组已完全填充