Johann Bauer
Johann Bauer

Reputation: 2606

.gitignore does not ignore one folder

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/?

Upvotes: 21

Views: 20121

Answers (4)

Farhan
Farhan

Reputation: 3363

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

Upvotes: 58

user2167877
user2167877

Reputation: 1706

I had same issue, I hope this will help you:

  • open your terminal and go to your root folder
  • execute: git rm -rf .gradle/
  • then execute this: git rm --cached .gradle -r
  • commit your changes and sync again

Upvotes: 2

hhk
hhk

Reputation: 81

This could be because the git is already tracking those files. Stop tracking that file then do a commit and push.

In Source Tree:

  • Right click the file and select stop tracking
  • Commit the changes
  • Push to origin

Upvotes: 3

klerk
klerk

Reputation: 396

This is common for dot(.) that are not included, add this to .gitignore

.*
!/.gitignore

Upvotes: 3

Related Questions