When developing code, it’s common to have files and directories that shouldn’t be committed to the Git repository. These might include build artifacts like object and compiled code, dependency caches, runtime files such as logs, temporary or lock files, IDE or editor-specific files, and hidden OS files like Thumbs.db or .DS_Store.
I often see entries like .DS_Store or .idea added directly to a project’s .gitignore, but this isn’t best practice. Not every developer uses the same tools or operating system, and maintaining a growing list of personal or environment-specific files in a shared repository can quickly become messy. The more appropriate approach — and one that should be considered a development standard — is to keep project-level .gitignore files focused solely on files relevant to the project. For everything else — your IDE, your OS, and your personal workflow — Git allows you to set up a global ignore file that applies across all your projects.
To setup a file with a list of items which should be ignored globally on your local system:
git config –global core.excludesfile ~/.gitignore_global
To view the currently set file:
git config –get core.excludesfile
My current file for use on macOS, which you should tailor to match your own tools and habits:
# General files .DS_Store .AppleDouble .Apple Double .LSOverride # Thumbnail cache files ._* Thumbs.db # Custom icon file (which ends with \r), but not other icon* entries Icon? ![iI]con[_a-zA-Z0-9] # Files which can be in root of an external volume .com.apple.timemachine.donotpresent .DocumentRevisions-V100 .fseventsd .Spotlight-V100 .TemporaryItems .Trashes .VolumeIcon.icns # Possible directories on a remote AFP share .apdisk .AppleDB .AppleDesktop .Apple Desktop Network Trash Folder Temporary Items # Application specific files/directories .idea/ .vscode *.code-workspace # Local WIP and Notes /_*.md /_ToDo /_Old /_Open /_WIP # Temporary test files /t /t.* /t-* /t[0-9] /t[0-9].*
Common editor, IDE and related tool file settings (to put in a global gitignore file):
.vscode,.code-workspace– VS Code.idea/– PhpStorm and other JetBrain.phpactor.json– Phpactor.fleet– JetBrains Fleet (lightweight IDE)*.sublime-project,*.sublime-workspace– Sublime Text.project,.settings– Eclipse IDEnbproject/,– Netbeans IDEtmproj– TextMate Editor*.swp,*.swo,*~– vi and vim*.diff– git diff, DiffMerge, Kaleidoscope, GNU Diffutils, etc.*.orig,*.rej– git apply/merge, patch utility, etc.*.esproj– JavaScript Project System (JSPS) in Visual Studio.zed– Zed (collaborative code editor built by the creators of Atom)*.komodoproject,.komodotools– Komodo Editdwsync.xml,_notes/– Adobe Dreamweaver
Common per-project settings (to keep in a project’s .gitignore):
- General
.env,.env.local,.env.backup.secrets/*.log– log files/composer.lock– when creating a composer package rather than an app
- Dependencies
/vendor/,/auth.json– Composernode_modules/– Node*.sass-cache– Sass/SCSS
- Laravel build/runtime
/public/build,/public/hot,/public/storage/storage/*.key,/storage/logs/*.log,/storage/pail/storage/app/public,/storage/framework/*
- Laravel Nova
/nova-components/vendor//nova-components/*/dist//nova-components/*/node_modules//nova-components/*/vendor/
- Laravel Homestead
Homestead.jsonHomestead.yaml
- Test and Coverage
.phpunit.results.cache.phpunit.cache/coverage/
- Other Source Control (normally not expected in Git projects
.svn/– SVN (Subversion).CVS/– CVS (Concurrent Versions System).hg/– Mercurial
