I'm finally trying to get on board with using Drupal 8 and want to know if I should ignore the vendor directory in git with .gitignore. I would assume not, but I've seen a few example .gitignore files that do.


4 Answers 4


There isn't really a right or wrong answer, it will come down to your situation. Composer themselves have pretty strong feelings that yes, you should ignore it, and in an ideal world that's definitely what you should do, but it's not always that straightforward.

It depends mainly on your hosting and deployment process. If, for example, you're on Pantheon, and don't wish to implement a complicated upstream workflow, involving a dialogue with their technical staff, you're forced to commit all dependencies to the repo. There's no Composer sitting at the other end waiting to run when your code is pushed, if you don't push those files up yourself, they're not there, and things will break.

Similarly if you're on shared hosting and don't have a CI workflow, you're probably going to be forced into lugging all the files around with you in one way or another.

Basically if it fits into your development/deployment workflow to be able to exclude those files, it's a good idea to (for the reasons listed in the link above).

If it doesn't, committing them to the repo is absolutely fine.


Drupal core and modules update so frequently, often with security fixes, that it has become common to use composer to manage dependencies. Composer will place dependencies in the vendor directory, and then you don't need to commit them to your codebase. You can run "composer install" on the server and it will download the dependencies on that server. This allows your code repository to be lighter. If you are using this process, you wouldn't want to commit the files, so yes, you'd want to gitignore that directory.

If you want to get up and running with using composer to manage a drupal site, you can check out the drupal scaffold project.


I would say yes. The composer.json file has version requirements and composer.lock specifies the exact versions that are installed. Having the composer.lock in version control effectively defines what is in the vendor directory and its history, therefore it is not necessary to have any history of the vendor directory itself.

Secondly, vendor directories tend to be HUGE, many times that of your own project so if you want to keep your repository lean, then don't commit the vendor directory.

  • So, do you mean "yes", ignore the /vendors?
    – Christia
    Commented Jul 2, 2022 at 6:07
  • Wow, I just read my comment and you’re right. I mistakenly said “no” to ignoring it. I may have been thinking “no” to committing it.
    – Oliver P
    Commented Jul 3, 2022 at 8:18

Honestly, @Clive had the correct answer. It depends on the environment. I've used Patheon extensively and I've worked with other Kuberneties-based hosting that dont have a CICD. In those cases you must version control your vendor files and frankly, I've never seen a performance drop because of it. It's not what the cool-kids around the water-cooler are doing, but it works just fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.