I've got the following in my .gitignore:
#built application files
*.apk
*.ap_
# files for the dex VM
*.dex
# Java class files
*.class
# generated files
bin/
gen/
# Local configuration file (sdk path, etc)
local.properties
# Windows thumbnail db
Thumbs.db
# OSX files
.DS_Store
# Eclipse project files
.classpath
.project
# Android Studio
.idea
build/
cache.properties.lock
.idea/workspace.xml
*.iws
.gradle/
**/.gradle/
However, whenever I make changes to my app, git includes files like .gradle/1.12/taskArtifacts/cache.properties.lock
to the commit.
What's wrong here? Why does it work with the folder build/
but not with .gradle/
?
gitignore is a plain text file in which each line contains a pattern for files or directories to ignore. It uses globbing patterns to match filenames with wildcard characters. If you have files or directories containing a wildcard pattern, you can use a single backslash ( \ ) to escape the character.
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.
If you want to ignore a file that you've committed in the past, you'll need to delete the file from your repository and then add a . gitignore rule for it. Using the --cached option with git rm means that the file will be deleted from your repository, but will remain in your working directory as an ignored file.
A . gitignore file is a plain text file where each line contains a pattern for files/directories to ignore. Generally, this is placed in the root folder of the repository, and that's what I recommend. However, you can put it in any folder in the repository and you can also have multiple .
It is possible that Git is already tracking these files. Running the following command in terminal worked for me for both .gradle
and .idea
files:
git rm --cached .gradle -r
This is common for dot(.) that are not included, add this to .gitignore
.*
!/.gitignore
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