VS Code .gitignore template
The VS Code template ignores everything in the editor folder except five files that a team usually does want to share: settings, tasks, launch, extensions and snippets.
At a glance
- Category
- IDE
- Patterns in this template
- 8 rules
- Directories ignored
- 1 of the 8 rules end in a slash, so they match directories only
- Re-include rules
- 5 lines start with ! to keep something back
- Also needs an OS template
- Yes. Editor rules and operating system rules cover different things entirely.
- Typical companions
- Whatever language or framework template matches the project itself.
In detail
The first rule is .vscode/* and not .vscode/, and that difference is the entire design. Ignoring the directory means git never looks inside it, so no later negation can bring anything back. Ignoring the contents means git still descends into the directory and the negations that follow are actually consulted. Anyone who writes .vscode/ and then wonders why their exceptions do nothing has hit exactly this.
The five files kept back are the ones with a genuine shared purpose. settings.json holds project settings such as the formatter, tab width and which files to hide. extensions.json recommends the extensions this project expects, so a new developer gets a prompt rather than a list in a README. tasks.json defines build commands and launch.json defines debug configurations, both of which encode knowledge about how the project runs.
The case against committing any of it is real too. Editor configuration is personal, a settings file can override preferences somebody deliberately set, and a repository that carries configuration for one editor implicitly asks everyone to use it. Teams that feel strongly usually ignore the directory entirely and move formatter settings into a tool config file that every editor reads.
The practical middle ground is what this template encodes: share the files that describe the project, ignore the files that describe your session. Everything not negated is the second kind, including per workspace state the editor writes as you work.
.history is the local file history directory an extension creates, holding a timestamped copy of every save. *.vsix is a packaged extension, which only appears in a repository that builds one. The history directory in particular grows without bound and duplicates work git already does, so it is one of the few editor artefacts that is a nuisance on disk as well as in a diff.
Examples
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets
.history/
*.vsix8 lines exactly as the tool writes them, before any common additions you tick.
.vscode/
!.vscode/settings.json
.vscode/*
!.vscode/settings.jsonThe first pair does not work: git excludes the directory and never descends into it, so the negation is never evaluated. The second pair does.
Things that catch people out
- A negation cannot re-include a file inside an ignored directory. Write .vscode/* rather than .vscode/, otherwise every ! line below it is silently ineffective.
- settings.json is committed by this template, so a personal preference you set at the project level travels to everyone. Put personal settings in your user profile instead.
- If someone previously committed the whole .vscode directory, adding this template does not untrack the extra files. Use git rm --cached on them first.
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 →IntelliJ IDEA .gitignore template
The IntelliJ template ignores the whole .idea directory and the module files, which is simpler than the alternative and loses some settings worth sharing.
Vim .gitignore template
The Vim template uses character ranges to catch every swap file extension the editor cycles through, plus sessions, undo history and the netrw history.
Sublime Text .gitignore template
The Sublime template separates the project file from the workspace file, and covers sftp-config.json, which stores upload credentials in plain text.
Eclipse .gitignore template
The Eclipse template ignores the project descriptor, classpath file and settings folder, which is right for a build tool project and wrong without one.
Emacs .gitignore template
The Emacs template covers tilde backup files, the hash delimited auto save files, the symbolic lock files and compiled Lisp, plus per project tooling state.
Xcode .gitignore template
The Xcode template ignores the project bundle's contents while keeping the project file and shared data, the only way to share schemes but not sessions.
Tools for this
- .gitignore Generator Generate .gitignore files for any project - 50+ templates for languages, frameworks, IDEs, and OS
- Git Commit Message Generator Free online git commit message generator - generate conventional commit messages with type, scope, and description