Eclipse Android 和 gitignore

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3325736/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 09:43:26  来源:igfitidea点击:

Eclipse Android and gitignore

androideclipsegit

提问by user401120

What files/folders can I safely ignore for inclusion with git?

我可以安全地忽略哪些文件/文件夹以包含在 git 中?

I copied a good project, removed its gen and bin folders and tried to run the app. The Android Launch window says, "Your project contains error(s), please fix them before running your application. There is a red X on the icon to the left of the project in the Package Explorer. While the gen folder does not exist in Windows Explorer, it does in Package Explorer.

我复制了一个好的项目,删除了它的 gen 和 bin 文件夹并尝试运行该应用程序。Android 启动窗口显示:“您的项目包含错误,请在运行应用程序之前修复它们。包资源管理器中项目左侧的图标上有一个红色的 X。而 gen 文件夹不存在于Windows 资源管理器,它在包资源管理器中。

回答by Vik Gamov

There are file types to ignore

有一些文件类型可以忽略

# built application files
*.apk
*.ap_

# files for the dex VM
*.dex

# Java class files
*.class

# generated files
bin/
gen/

# Local configuration file (sdk path, etc)
local.properties

# Eclipse project files
.classpath
.project

# Proguard folder generated by Eclipse
proguard/

# Intellij project files
*.iml
*.ipr
*.iws
.idea/

From Gitignore on github

来自github 上的 Gitignore

回答by Cristian

What I usually add to .gitignoreis:

我通常补充的.gitignore是:

bin
gen

binand genare constantly changed while coding, so there's no need to include them into the Git repository. Also, sometimes I add .classpathand .projectwhich are Eclipse specific files, because maybe I want to create a new Android project based on these same sources, but in another OS or IDE.

bin并且gen在编码时会不断更改,因此无需将它们包含到 Git 存储库中。此外,有时我会添加.classpath.project哪些是 Eclipse 特定文件,因为也许我想基于这些相同的源创建一个新的 Android 项目,但在另一个操作系统或 IDE 中。

With regards to the error, I would clean the project and/or try to run the Fix Project Propertiesutility (right-click on the Project -> Android Tools -> Fix Project Properties).

关于错误,我会清理项目和/或尝试运行修复项目属性实用程序(右键单击项目 -> Android 工具 -> 修复项目属性)。

回答by Diego Freniche

Best solution today is probably to generate the exact .gitignore file you need. Just go to http://www.gitignore.io

今天最好的解决方案可能是生成您需要的确切 .gitignore 文件。只需访问http://www.gitignore.io

The project is also on Github: https://github.com/joeblau/gitignore.io

该项目也在 Github 上:https: //github.com/joeblau/gitignore.io

回答by QRohlf

It's safe to ignore bin and gen, without problems. When I have problems with a project setup, I do this: First - have you looked at the 'Problems' tab in the view underneath the editor view - it generally gives more detailed information about project errors. If there's nothing conclusive there, I do the things below:

忽略 bin 和 gen 是安全的,没有问题。当我在项目设置方面遇到问题时,我会这样做:首先 - 您是否查看了编辑器视图下方视图中的“问题”选项卡 - 它通常提供有关项目错误的更多详细信息。如果那里没有定论,我会做以下事情:

  1. Generally, when I'm having issues with Eclipse giving me phantom errors in the project, cleaning the project will fix it. It's in the menu, under Project>Clean.
  2. If that doesn't work, I'll usually try right clicking the project, going to Android Tools> Fix project properties.
  3. My last resort it to restart eclipse and delete the gen folder.
  1. 通常,当我遇到 Eclipse 问题时,我在项目中出现幻影错误,清理项目将修复它。它位于菜单中的 Project>Clean 下。
  2. 如果这不起作用,我通常会尝试右键单击项目,转到 Android 工具 > 修复项目属性。
  3. 我最后的手段是重新启动 eclipse 并删除 gen 文件夹。

回答by Hymany

the best way is use this site to generate: http://www.gitignore.io/

最好的方法是使用这个站点来生成:http: //www.gitignore.io/

回答by Justin Buser

The simple answer to this question is *.* , basically it's completely safeto ignore anything you don't want to add to version control. That being said it really depends on what you're looking to accomplish by using Git. If you want to be able to checkout/import your project elsewhere from the same repository then you'll want to ignore at most /bin/.and /gen/., I wouldn't ignore the folders themselves (i.e. /bin, /gen) just for the sake of maintaining the proper directory structure for your project.

这个问题的简单答案是 *.* ,基本上忽略您不想添加到版本控制的任何内容是完全安全的。话虽如此,这实际上取决于您希望通过使用 Git 来完成什么。如果您希望能够从同一存储库的其他位置签出/导入您的项目,那么您最多需要忽略 /bin/ 和 /gen/ ,我不会为了维护项目的正确目录结构而忽略文件夹本身(即/bin、/gen)。

That answers the initial question, but is unrelated to the problem you are having. As far as solving the problem you are experiencing is concerned you would have to post more info, specifically what's listed in the Problems tab. If you can't see the Problems tab anywhere then click on the Window menu, then show view, then choose problems if it's there or click on other and look under General to find it.

这回答了最初的问题,但与您遇到的问题无关。就解决您遇到的问题而言,您必须发布更多信息,特别是“问题”选项卡中列出的内容。如果在任何地方都看不到“问题”选项卡,请单击“窗口”菜单,然后显示视图,然后选择问题(如果存在)或单击“其他”并在“常规”下查找以找到它。