【问题标题】:Git wont ignore /build/intermediates/ files even though I added build/ to .gitignore即使我将 build/ 添加到 .gitignore,Git 也不会忽略 /build/intermediates/ 文件
【发布时间】:2015-09-16 11:51:19
【问题描述】:

我正在 android studio 中进行 android 开发,我试图忽略所有 /build/ 文件,但它不起作用。这是我当前的 .gitignore 文件

# built application files
*.apk
*.ap_

# files for the dex VM
*.dex

# Java class files
*.class

# built native files
*.o
*.so

# generated files
bin/
gen/

# Ignore gradle files
.gradle/
build/

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

# Proguard folder generated by Eclipse
proguard/

# Eclipse Metadata
.metadata/

# Mac OS X clutter
*.DS_Store

# Windows clutter
Thumbs.db

# Intellij IDEA (see https://intellij-support.jetbrains.com/entries/23393067)
.idea/workspace.xml
.idea/tasks.xml
.idea/datasources.xml
.idea/dataSources.ids

.*
!/.gitignore

但是当我执行 git status 时,仍然会出现构建文件

【问题讨论】:

  • 您需要在项目中的每个模块中添加一个.gitignore文件

标签: android git github


【解决方案1】:

它们可能是在 添加到 .gitignore 文件之前添加到 repo 中的。您应该使用 git rm --cached filename.ext 从 repo 中删除它们,并提交(连同 .gitignore 文件)。

【讨论】:

  • git rm --cached filename.ext 不起作用。我应该用什么替换“filename.ext”吗?
  • 是的,您实际上想要删除/忽略的文件。当然,您可以使用通配符,因此您不必为每个单独的文件都这样做(希望如此!)
  • 实际上,只需执行git rm --cached buid/,因为它看起来就是您要忽略的目录。
  • 太棒了。太感谢了!你知道如何忽略 .iml 文件吗?
  • git rm --cached /actual_path/to/files/*.iml.
猜你喜欢
  • 2019-04-18
  • 1970-01-01
  • 2018-05-02
  • 1970-01-01
  • 2011-03-18
  • 2013-07-23
  • 2021-09-29
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多