Search code examples
laravelgithubcomposer-phpgitignore

.gitignore does not work for subfolder of ignored folder


I'm using Laravel and the Github program for subversions. In my .gitignore file i type:

/vendor

My project structure looks like this:

Root
 app
 bootstrap
 public
 vendor

And it's all the files in vendor i want to ignore in git. Most of the files works to ignore there with typing /vendor in my .gitignore, but some files don't.

The files that doesn't work are autoload.php - vendor/autoload.php

And files in vendor/composer - like:

autoload_classmap.php
autoload_namespaces.php
autoload_real.php
ClassLoader.php
installed.json

What am i doing wrong in my .gitignore file?


Solution

  • After adding vendor folder in gitignore did you clear the git cache

    git rm -r --cached vendor
    
    git add .
    git commit -m ".gitignore"
    

    This will remove vendor folder completely.