Laravel .gitignore template
The Laravel template ignores the environment file and its variants, application encryption keys, the built asset output and the editor directories the framework scaffolds around.
At a glance
- Category
- Framework
- Patterns in this template
- 20 rules
- Directories ignored
- 3 of the 20 rules end in a slash, so they match directories only
- Also needs an OS template
- Yes. The template covers two editors but nothing from the operating system.
- Typical companions
- PHP for the vendor rules, plus an OS template. The editor rules are already here.
In detail
This template is unusual because it spends most of its rules on secrets rather than build output. .env, .env.backup and .env.production are all covered. That file holds the database credentials, the mail transport password, the application key and every third party API key the project uses, and the framework reads it at boot rather than from the deployment environment, which is why it exists on disk at all.
/storage/*.key is the application key file, and auth.json holds registry credentials for private package repositories. Both are live secrets. The pattern here is worth internalising: any rule matching *.key or a credentials file is not tidying, it is the difference between a private repository and a public incident.
/public/build and /public/hot are asset pipeline output. The build directory holds the bundled JavaScript and stylesheets with their content hashes, produced from sources that are already tracked. The hot file exists only while a development server is running and contains the URL that server is listening on. /public/storage is a symbolic link to the storage directory, created by a console command rather than checked in.
The /.idea, /.vscode and /.fleet rules are anchored editor directories. Including them in a framework template is a pragmatic choice: a large share of projects use one of those editors, and anchoring means only the root level directory is covered, so a package inside the project keeping its own settings is unaffected.
/vendor and /node_modules cover both dependency trees, since a full stack project has one of each. .phpunit.result.cache stores which tests passed last run so the runner can reorder them, and /storage/pail is a log viewer's working directory. The Homestead files describe one developer's local virtual machine.
Examples
/vendor/
/node_modules/
/public/build/
/public/hot
/public/storage
/storage/*.key
/storage/pail
.env
.env.backup
.env.production
.phpactor.json
.phpunit.result.cache
Homestead.json
Homestead.yaml
auth.json
npm-debug.log
yarn-error.log
/.fleet
/.idea
/.vscode20 lines exactly as the tool writes them, before any common additions you tick.
Things that catch people out
- Ignoring .env only stops future commits. If it was ever committed, the credentials are in the history of every clone, so rotate them rather than assuming a removal is enough.
- The template does not ignore .env.example, which is intentional: that file is how a new developer learns which keys exist, and it should be committed with blank values.
- /public/storage is a symbolic link. Ignoring it is right, but a deploy that forgets to recreate the link produces missing images with no error in the logs.
Try it: .gitignore Generator
Pick one or more templates, tick the common additions you want, and copy or download the combined .gitignore.
.gitignore Generator
LOCAL · Browser-OnlyGenerate comprehensive .gitignore files by combining templates for languages, frameworks, IDEs, and operating systems
Language
Framework
IDE
OS
Build Tool
Infrastructure
Common Additions
Preview
Select templates or common additions to generate a .gitignore file.
Related .gitignore templates
All .gitignore templates →PHP .gitignore template
The PHP template ignores the vendor directory and the .env file, and also ignores composer.lock, which most application projects should commit instead.
Node.js .gitignore template
The longest JavaScript oriented template: dependency directories, every package manager's debug log, bundler caches, env files and Yarn Plug'n'Play state.
VS Code .gitignore template
This template ignores the .vscode folder's contents but keeps five files back on purpose, which is the clearest statement of the commit or ignore argument.
React .gitignore template
A short template built around one idea: the .env.local family is per developer and never committed, while the plain .env is shared and usually should be.
Next.js .gitignore template
What the Next.js template ignores: the build cache, the static export folder, deployment state, and one wildcard that covers every local environment file.
Vue .gitignore template
The Vue template ignores build output and local environment files, and is one of the few that also carries operating system and editor rules of its own.
Tools for this
- .gitignore Generator Generate .gitignore files for any project - 50+ templates for languages, frameworks, IDEs, and OS
- .env Editor & Validator Edit and validate .env files online - detect duplicates, mask secrets, generate .env.example