Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is git looking inside vendors directory?

I have the .gitignore file with this code:

/app/cache/* /app/logs/* /app/bootstrap* /vendor/* /web/bundles/ /app/config/parameters.yml 

but when I do :

$ git status 

in any situation (before and after add and commit), I get a long text output like this:

    ...      #   deleted:    vendor/doctrine/orm/tools/sandbox/cli-config.php     #   deleted:    vendor/doctrine/orm/tools/sandbox/doctrine     #   deleted:    vendor/doctrine/orm/tools/sandbox/doctrine.php     #   deleted:    vendor/doctrine/orm/tools/sandbox/index.php     #   deleted:    vendor/doctrine/orm/tools/sandbox/xml/Entities.Address.dcm.xml     #   deleted:    vendor/doctrine/orm/tools/sandbox/xml/Entities.User.dcm.xml     #   deleted:    vendor/doctrine/orm/tools/sandbox/yaml/Entities.Address.dcm.yml     #   deleted:    vendor/doctrine/orm/tools/sandbox/yaml/Entities.User.dcm.yml     #   modified:   vendor/friendsofsymfony/user-bundle/FOS/UserBundle     #   modified:   vendor/gedmo/doctrine-extensions     #   modified:   vendor/herzult/forum-bundle/Herzult/Bundle/ForumBundle     #   modified:   vendor/kriswallsmith/assetic     #   modified:   vendor/symfony/property-access/Symfony/Component/PropertyAccess/.gitignore     #   modified:   vendor/symfony/property-access/Symfony/Component/PropertyAccess/StringUtil.php     #   modified:   vendor/symfony/symfony/CHANGELOG-2.1.md      ... 

The vendors directory is in .gitignore file, so I don't know what is happening. I've tried with:

$ sudo git clean -dxf 

but nothing changes.

like image 451
Manolo Avatar asked Sep 11 '13 18:09

Manolo


People also ask

How do I ignore a directory vendor in git?

gitignore files says to ignore /vendor directory, use git add -f if you really want to include them.

Should I commit the dependencies in my vendor directory?

The general recommendation is no. The vendor directory (or wherever your dependencies are installed) should be added to . gitignore / svn:ignore /etc. The best practice is to then have all the developers use Composer to install the dependencies.


1 Answers

Your vendor directory is checked in to the repo. To remove it, go to your git repo root and run:

git rm -r --cached vendor 

This will recursively (due to -r flag) remove vendor from your git repo. The --cached flag will keep the local copy of vendor directory in tact. Note that if there are other devs working with the repo, their copy of the vendor directory will be removed and they will need to bundle install again.

Once you've untracked the directory in git, you can commit the change using:

git commit -m "untrack vendor directory" 

Thereafter, .gitignore will happily ignore any changes within the vendor directory next time onwards.

Also, you don't need your entries in .gitignore to begin with a /. Use the / when you want to ensure that only files/folders in root directory are ignored, and any file in a subdirectory matching the pattern should not be ignored.

like image 112
Anshul Goyal Avatar answered Oct 05 '22 01:10

Anshul Goyal