Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gitignore not ignoring some build files in Android library

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

I have tried modifying my .gitignore and also following these steps, but this doesn't change anything.

Here is my top-level .gitignore (which can also be found on the GitHub repo):

# Gradle files
.gradle/
build/
*/build/

# Local configuration file (sdk path, etc)
local.properties

# IntelliJ
*.iml
/.idea

The module with the build folder that isn't being ignored has the following .gitignore:

/build/

I'm not sure why the build directory isn't being ignored, as it is being ignored in my sample app module, and in the top-level directory.

Also, I did commit changes to some files in the build directory when I updated versions of my library, if that's important.

like image 414
Farbod Salamat-Zadeh Avatar asked Apr 08 '16 11:04

Farbod Salamat-Zadeh


People also ask

Why is .gitignore not ignoring my files?

gitignore ignores only untracked files. Your files are marked as modified - meaning they were committed in the past, and git now tracks them. To ignore them, you first need to delete them, git rm them, commit and then ignore them. Igal S.

Why isn't my Gitignore working?

The Solution To resolve the problem remove from the repository the tracked files contained in the . gitignore file. To achieve this use “git rm” to remove and untrack all the files in the repository, then use “git add” to re-add all the files (the files contained in the .


1 Answers

This answer on Stack Overflow helped me solve my issue.

Here is part of that answer:

First commit any outstanding code changes, and then, run this command:

git rm -r --cached .

This removes any changed files from the index(staging area), then just run:

git add .

Commit it:

git commit -m ".gitignore is now working"

like image 105
Farbod Salamat-Zadeh Avatar answered Oct 17 '22 21:10

Farbod Salamat-Zadeh