Removing the vendor folder in Laravel from Git can be tricky and a bit overwhelming if you’re not familiar with the process. Fortunately, there are several ways to go about this task and we’ll cover the two most common methods in this tutorial.
In case you have accidentally committed your vendor folder, you can easily remove it by following these steps:
git rm -r --cached vendor git rm -r --cached composer.lock git commit -m "untrack vendor directory" git push
This is the most common and straightforward approach to exclude the vendor folder from Git. To do this, you need to create a .gitignore file in the root directory of the Laravel project. Inside this file, add the following line:
Save the file and add it to the repository. This will tell Git to ignore the vendor folder and all its contents.
This my .gitignore content:
/node_modules /public/hot /public/storage /storage/*.key .phpunit.result.cache docker-compose.override.yml Homestead.json Homestead.yaml npm-debug.log yarn-error.log composer.lock /.idea /.vscode .env /vendor/