When you first started to use Git, we asked you to use a
.gitignore_global file to tell Git not to track certain files, like
.Trashes. In PHP, we don't want Git to track our dependencies in our
vendor folder. This is because each dependency adds numerous files to your project and those files are never altered by you. If you do track those files, and then you try to
$ git clone that repository, it will take a very long time for your computer to pull all of those files down from your repo. So go ahead and make a
.gitignore file in your project folder and include
vendor/ to prevent those vendor files from being tracked.
You might ask yourself, "Well, how will someone who wants to clone my repository know what dependencies are needed for my program?" There is a very simple solution, since you will have created a
composer.json file which lists all of the dependencies for your project. Just include an instruction to run
$ composer install in your
README, once they have cloned your repository. This will set up the correct dependencies on their computer.
If you would like to go back and remove the files in your
vendor folder for projects you have already created repositories for in Git, do the following in your project folder:
$ git rm -r --cached .
$ git add .
git commit -m "add vendor folder to .gitignore"