Resolves git-ignores files, adds Gitignore, and processes already track files

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.