Answer the question
In order to leave comments, you need to log in
Why doesn't .gitignore work for a new project in Android Studio?
I created a project which has a .gitignore file with a lot of content. After that, I initialized Git through the console and made a commit. But I still don't understand why it committed my files from .gitignore? What did I do wrong? The sequence of entered commands is in the screenshots.
.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/
Answer the question
In order to leave comments, you need to log in
You have a very old git -- update.
Are there sure to be no spaces or other characters at the end of lines in the .gitignore file?
https://git.kernel.org/cgit/git/git.git/tree/Docum...
Updates since v1.9 series
* Trailing whitespaces in .gitignore files, unless they are quoted
for fnmatch(3), eg "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.
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).
For git ignore to work, it must be in the repository before you commit anything else.
git add .gitignore
git commit -m 'add .gitignore'
git push
git add .
git commit -m 'initial commit'
git push
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question