Keeping Files Out of Git: ignore, exclude, and the Global File

Keeping Files Out of Git: ignore, exclude, and the Global File

21 October 2026 · By Laravel Git · 2 min read

What Not to Commit in a Laravel Project covers which files stay out of the repo. This is the mechanics post: Git gives you three different places to say “ignore this”, and they are not interchangeable.

.gitignore: the shared, committed one#

The .gitignore at the root of the repo is committed, so every clone gets it. This is where project-level rules live - Laravel’s default file already covers the essentials:

/vendor
/node_modules
.env
/storage/logs

If a file would be junk for anyone who clones the project, its rule belongs here.

.git/info/exclude: private to your clone#

This file works exactly like .gitignore but is not committed or pushed. Use it for things only your checkout produces - a scratch script you keep in the project root, a local docker-compose.override.yml nobody else has. Nobody else’s repo should carry rules for your personal files.

The global file: private to your machine#

Editor and OS noise follows you across every project, so Git lets you ignore it once, everywhere:

git config --global core.excludesFile ~/.gitignore_global

Put .idea/, .vscode/, .DS_Store and friends in there. If every project’s committed .gitignore carries editor rules, that is a sign this file is missing on someone’s machine.

When the file is already tracked#

An ignore rule does nothing for a file Git is already tracking - the classic case is a .env committed before the rule existed. Untrack it without deleting your local copy:

git rm --cached .env

Commit that removal and the ignore rule takes over from there. Note the file still exists in history; if what slipped in was a secret, untracking is not enough - see A Secret Got Committed. Now What?.

One last habit: run git status before committing and actually read the list. Ignoring rules prevent accidents, but the status list is where you catch the ones that got through.

Share this post

Our network