A Laravel repo should hold the recipe, not the kitchen. The generated and environment-specific parts belong elsewhere.
The .gitignore that covers it#
/vendor
/node_modules
.env
.env.backup
.phpunit.result.cache
/public/build
/public/hot
/storage/*.key
/storage/logs/*.log
Homestead.json
Homestead.yaml
Laravel’s default .gitignore ships most of this. The ones people add by hand are the environment files and the editor/OS noise (.idea, .DS_Store — those belong in your global gitignore, not the project’s).
Why each one stays out#
vendor/andnode_modules/are rebuilt bycomposer installandnpm cifrom the lock files — which you do commit..envis per-machine by definition and carries secrets. Commit.env.examplewith the keys and empty values instead.public/buildis Vite output; it gets rebuilt on every deploy.storage/*.keyand logs are runtime state, different on every server.
Already committed something?#
git rm --cached -r vendor stops tracking it without deleting your local copy, then commit the removal. If the file carried a secret, that is not enough — the history still has it, and the rotate-first routine applies.
Share this post
Keep reading
Git Bisect: Find the Commit That Broke It
The tests passed last week and fail now. Bisect turns 'somewhere in these 40 commits' into six test runs.
The Reflog: Undoing Almost Anything in Git
Reset too far, deleted the wrong branch, botched a rebase? The reflog remembers where HEAD has been, and that is usually enough.
What to Do in a Detached HEAD
Detached HEAD sounds like an injury. It is just HEAD pointing at a commit instead of a branch - safe to look around, one command to keep any work.