在Windows上将dir添加到gitignore

时间:2016-09-04 21:00:28

标签: windows git smartgit

我在Windows上使用smartgit。

我正在尝试在repo中添加一些要忽略的目录。

我正在使用以下.gitignore,建议用于Android Studio Android应用程序。

#built application files
*.apk
*.ap_

# files for the dex VM
*.dex

# Java class files
*.class

# generated files
bin/
gen/
build/

# 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/

#NDK
obj/

据我了解,应该忽略Build文件夹,但不会被忽略。此外,Build \ Generated文件夹被忽略,但该目录甚至没有添加到gitignore文件中。

在这里,您可以看到生成文件夹未被忽略,而生成的文件夹是。

enter image description here

1 个答案:

答案 0 :(得分:2)

有了这个

build/

你告诉git完全跳过build目录,所以它会自动忽略该路径中的任何文件或目录。

因此正确地忽略了generated目录。

现在,intermediate包含的唯一原因(给定你的gitignore)是它在被忽略之前已经在repo上提交了。

如果要开始忽略它,则需要先使用

将其删除
git rm -r --cached build/intermediate

作为奖励,如果你想忽略一个目录,而不是你可以做的子目录

build/*
!generated

以下是关于该主题的更全面的解释:.gitignore exclude folder but include specific subfolder