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.
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.
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 .
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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With