android - 从 Android Studio Gradle 项目的 GIT 中排除的文件,以维护 MAC 和 Windows 中的代码。

标签 android windows git macos gradle

我在 MAC - OSX 中编写代码,我的合作伙伴在 PC - Windows 中编写代码,但是当我提交并推送更改时,项目目录中有多个文件以 .IML 或 .config 或 .properties 结尾,这些文件会被覆盖并导致频繁覆盖很麻烦。

所以我的问题是哪些文件可以从 Android Studio Gradle 项目的 GIT 中排除以维护 MAC 和 Windows 中的代码?最好的方法是什么?

最佳答案

这是一个不错的 .gitignore 文件,您将其放在项目的根目录中,例如.git 文件夹所在的文件夹:

#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

# Windows thumbnail db
Thumbs.db

# OSX files
.DS_Store

# Eclipse project files
.classpath
.project

# Android Studio
*.iml
.idea/
#.idea/workspace.xml - remove # and delete .idea if it better suit your needs.
.gradle/
build/

app/build/

gradle/

#NDK
obj/

然后执行以下命令来应用.gitignore:

git rm -r --cached .
git add .
git commit -m "fixed untracked files"

查看更多here .

编辑:我还推荐使用 .gitignore plugin适用于 Android Studio。

关于android - 从 Android Studio Gradle 项目的 GIT 中排除的文件,以维护 MAC 和 Windows 中的代码。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39579936/

相关文章:

android - Eclipse 说需要更新的 ADT 版本,但找不到更新

android - 更改 ListView 或回收 View 的单个项目的布局

Android App + Library 与 appcompat 版本冲突

c++ - 如何为跨平台 C++ 开发设置 Visual Studio

java - 使用 JGit 的现有存储库的空标签列表

.net - 使用 Git Extensions for Visual Studio 将单个文件恢复为早期提交

android - 如何在整个项目中找到特定的警告

Windows 10 x64 的 MySQL msi 安装,更改安装文件夹?

windows - IIS 无法访问文件,但通过同一帐户登录的用户可以

git - 使用 `git commit --amend` 后旧提交会发生什么?