【问题标题】:Android studio - gitignore fileAndroid 工作室 - gitignore 文件
【发布时间】:2016-05-08 13:17:57
【问题描述】:

我刚开始使用 git 并创建了 .gitignore 文件,在我对其中一个 java 文件进行更改后,我看到 git 不会从假设被忽略的文件中忽略。例如:

假设只有 Logger.java 被提交,其他两个文件没有。

这是我的 .gitignore 文件:

# Built application files
*.apk
*.ap_

# Files for the Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/
out/

# Gradle files
.gradle/
build/

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

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log

# Android Studio Navigation editor temp files
.navigation/

# Android Studio captures folder
captures/

# Intellij
*.iml

# Keystore files
*.jks

【问题讨论】:

  • 我想你把你的 gitignore 文件放在这里了:gitignore.io/api/android 但你从来没有提到忽略这两个文件

标签: android git gitignore


【解决方案1】:

我想你把你的 gitignore 文件放在这里了:gitignore.io/api/android 但你从来没有提到忽略这两个文件......
也许你应该在你的 .gitingore 中添加这两行

.idea/workspace.xml
.idea/misc.xml

如果您已经提交了文件,您可能需要从 git 中删除这些文件。
看到这个帖子:Cannot ignore .idea/workspace.xml - keeps popping up

【讨论】:

  • 我个人将这些用于我的 android studio 忽略文件:# Android Studio / IntelliJ IDEA *.iws .idea/libraries .idea/tasks.xml .idea/vcs.xml .idea/workspace.xml .idea/misc.xml .idea/gradle.xml
  • 我只是给出这些文件,例如,有时会出现在 15-20 个文件之间,我无法将它们全部添加到 .gitignore
【解决方案2】:

您需要将.idea 添加到忽略列表中:

# Add it with the / at the end (since you want to ignore all the folder)
.idea/

# Now remove the files you have already added to the repo
git rm --cached .idea/*

这些文件由 JetBrain 产品(在您的情况下为 android studio IDE)生成,您必须将文件夹标记为已忽略。

【讨论】:

    猜你喜欢
    • 2022-10-14
    • 1970-01-01
    • 2018-12-29
    • 1970-01-01
    • 1970-01-01
    • 2020-11-13
    • 2017-07-21
    • 2020-06-16
    • 2016-04-05
    相关资源
    最近更新 更多