Gitignore doesn't ignore some build files in Android library

I have an Android library , and for some reason, the files and folders that I specified in my .gitignore are not ignored.

I tried to modify my .gitignore as well as the following these steps , but that doesn’t change anything.

Here is my top level .gitignore (which can also be found in the GitHub repository ):

 # Gradle files .gradle/ build/ */build/ # Local configuration file (sdk path, etc) local.properties # IntelliJ *.iml /.idea 

A module with a build folder that is not ignored has the following .gitignore :

 /build/ 

I am not sure why the build directory is not ignored, as it is ignored in the sample application module , and in the top-level directory .

In addition, I actually made changes to some of the files in the build directory when I updated versions of my library, if that was important.

+5
source share
2 answers

This stack overflow answer helped me solve my problem.

Here is part of the answer:

First make any code changes , and then run this command:

git rm -r --cached .

This removes any modified files from the index (staging area) and then runs:

git add .

Commit it:

git commit -m ".gitignore is now working"

+7
source

You have to remove the first / lower level gitignore before building, then it will work. In addition, at the top level, you only need the following: build/ , and then a higher level of gitignore is not required.

+1
source

Source: https://habr.com/ru/post/1246692/


All Articles