How to add and ignore files when Android uses version control tools (detailed explanation)

When Android studio cooperates with SVN, it is relatively simple to add ignored files. First, open the settings option of the project and switch to the ignored files directory under version control, as shown in the following figure:

ignore1.png

Click the green plus sign in the upper right corner to open the following dialog box:

ignore2.png

among

The ignore specified file option is to ignore the specified files. The ignore all files under option is to ignore the files in the specified folder. The ignore all files matching option is to ignore the files matching the specified format

Generally, the files to be ignored are as follows:

1. . idea folder

2. . gradle folder

3. All build folders

4. All. IML files

5. Local.properties file

Select the corresponding option according to the requirements and add the file to be ignored. The following figure is the ignored file added by my test project:

ignore3.png

After adding, the corresponding files in the directory structure of the project will change into the following styles:

ignore4.png

When submitting the file again, you will find that the ignored file (i.e. the file with yellow font color) will not appear in the submission list of SVN.

2、 Add ways to ignore files when managing projects with Git

After Android studio creates a project, a. Gitignore file will be generated in the root directory of the project. It is recommended to write the. Gitignore file of Android project as follows:

That is, the. Gitignore file writing format officially recommended by GitHub: android.gitignore. Of course, we can continue to add it as needed, for example, under # IntelliJ:

*.iws.idea/

Examples of relevant filtering rules: #: comment symbols, automatically ignored by git *. IML: filter all files with. IML suffix. Gradle /: filter out. Gradle folder local.properties: filter out local.properties files

Git file neglect is achieved by writing a. Gitignore file. Later, files ignored through. Gitignore will not be submitted to GitHub. Compare the project directory of the local as with the project directory submitted to GitHub:

local.PNG

github.PNG

Whether the project is managed through SVN or git, it is recommended to do a good job of ignoring files at the beginning of the project creation, and then submit them to the server.

The above article on how to add ignore files when using version control tools for Android (detailed explanation) is all the content shared by Xiaobian. I hope it can give you a reference and support more programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>