为什么 .gitignore 不适用于 Android Studio 中的新项目?

Why .gitignore not working for the new project in Android Studio?

我在 Android Studio 中使用 .gitignore 文件创建了项目。

.DS_Store

# built application files
*.apk
*.ap_

# files for the dex VM
*.dex

# Java class files
*.class

# generated files
bin/
out/
gen/

# Libraries used by the app
# Can explicitly add if we want, but shouldn't do so blindly.  Licenses, bloat, etc.
/libs


# Build stuff (auto-generated by android update project ...)
build.xml
ant.properties
local.properties
project.properties

# Eclipse project files
.classpath
.project

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

##Gradle-based build
.gradle
build/

在此之后,我在项目目录中使用了 git init 命令。

git status命令

git add .git status 命令

git commit命令

git status 命令为空值

Git 的版本是 1.9.1。我不明白为什么要添加这些文件以提交。

可能是1.9.1版本的bug

你应该更新 git。

Git v2.0 Release Notes

Updates since v1.9 series

  • Trailing whitespaces in .gitignore files, unless they are quoted for fnmatch(3), e.g. "path\ ", are warned and ignored. Strictly speaking, this is a backward-incompatible change, but very unlikely to bite any sane user and adjusting should be obvious and easy.

Git v2.1 Release Notes

Fixes since v2.0

  • Mishandling of patterns in .gitignore that have trailing SPs quoted with backslashes (e.g. ones that end with "\ ") has been corrected. (merge 97c1364be6b pb/trim-trailing-spaces later to maint).

Git 2.5 Release Notes

Fixes since v2.4

  • The codepaths that read .gitignore and .gitattributes files have been taught that these files encoded in UTF-8 may have UTF-8 BOM marker at the beginning; this makes it in line with what we do for configuration files already. (merge 27547e5 cn/bom-in-gitignore later to maint).