Lisa Anne
Lisa Anne

Reputation: 4595

What is wrong with my gitignore?

What is wrong with my .gitignore file?

build/
/build
/*/build/
/*/*/build/
build/

This is the structure of my directory:

myroot
    FacebookSDK
       +--src
       +--build
           +--foo
           +-- bar  
    app
       +--scr
       +--build         
    build
        +--other stuff...
        +--other stuff..
    .gitignore
    other stuff...

The problem is that foo and bar are not ignored!

What could be going wrong?

xxxxs-my:xxxx xxx$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

modified:   FacebookSDK/FacebookSDK.iml
modified:   FacebookSDK/build.gradle
modified:   FacebookSDK/build/intermediates/bundles/debug/classes.jar
modified:       FacebookSDK/build/intermediates/bundles/debug/res/drawable/com_facebook_button_blue.xml

Upvotes: 4

Views: 120

Answers (3)

Aditya Kadakia
Aditya Kadakia

Reputation: 1389

try using

build/
**/build/

in the .gitignore

If the files are already tracked use git rm --cached myfile to remove them from version control but keep them in local repo. Once removed from version control they should not get detected on change.

Upvotes: 0

Makoto
Makoto

Reputation: 106389

You should only need this rule, per the documentation:

**/build

This will exclude build folders globally.

If any of those folders had been added prior, you'd have to remove it from Git via git rm.

What's actually wrong with your .gitignore:

  • /build and build/ are equivalent; they will match a top-level build/ folder.
  • /*/build and /*/*/build wouldn't match anything.

Upvotes: 4

nicholaschiasson
nicholaschiasson

Reputation: 96

I believe it's because three of your ignore lines are from the root directory:

/build
/*/build/
/*/*/build/

when they should be from the current directory:

./build
./*/build/
./*/*/build/

Upvotes: 0

Related Questions