1. The question
Originally in the new project, as will automatically generate a. gitignore file, ignoring files that do not need to be track, such as the. idea folder, build folder, and so on, but I didn't realize at the beginning of the project that I was going to ignore the file and all the files were track, At this point, if you only Add. Gitignore will not take effect.
That is, Gitignore only takes effect on track files and does not take effect on files that have been track. For files that have already been track, adding gitignore files directly is not enough and requires additional action.
2. The solution
Follow these steps to resolve:
"Step1" executes the following command on the project Git bash
Git rm-r-f--cache.
(Plus-F indicates coercion) clears the trace of all files, and the last point represents the action object is all files.
"Step2" adds the. gitignore file in the project root directory and the app directory:
The contents of Gitignore are as follows, this document can be downloaded from the GitHub, can be found on the Internet
Here it is.
#built application Files
*.apk
*.ap_
# files for the Dex VM
*.dex
# Java class files
*.class
# generated files
bin/
gen/
out/
build/
# Local configuration file (SDK path, etc)
Local.properties
# Windows thumbnail db
thumbs.db
# OS X Files
. Ds_store
# Eclipse project Files
. classpath
. Project
# Android Studio
*.iml
. idea/
gradle/
# Local idea Workspace
# gradle cache
. Gradle
#NDK
obj/
After adding the file map:
When you create a project, you can specify the files to ignore under File->settings->ignorefiles, and you can automatically generate. gitignore files if you directly
adding. gitignore files does not require this step.
"Step3" executes in git bash
git Add.
1 1
At this point the Gitignore will take effect and will not add to the files that need to be ignored.
"Step4" executes in git bash
Git commit-m "Add Gitignore"
1 1
Submit changes.
The original text is from the point of view. http://m.blog.csdn.net/u011916937/article/details/75426661