# How to Ignore IDE-Specific Files Like .vscode and .idea in Git

> Easily ignore IDE-specific files like .vscode and .idea in Git using templates from github.gitignore. Keep your repository clean and focused on project code.

- Repository: [GitHub/gitignore](https://github.com/github/gitignore)
- Tags: how-to-guide
- Published: 2026-02-24

---

**Copy the official templates from the `github/gitignore` repository—specifically `Global/VisualStudioCode.gitignore` for VS Code and `Global/JetBrains.gitignore` for JetBrains IDEs—to exclude IDE metadata while preserving shareable project settings.**

The `github/gitignore` repository maintains community-curated ignore patterns for development environments. When you need to ignore IDE-specific files such as `.vscode` and `.idea` directories, these global templates provide optimized rules that filter out auto-generated metadata without removing configuration files your team actually needs. Each template uses negation patterns to distinguish between personal workspace data and legitimate project settings.

## VS Code: Ignoring the .vscode Directory

The `Global/VisualStudioCode.gitignore` template handles VS Code configuration by ignoring all files in the `.vscode` folder while explicitly un-ignoring specific JSON files you typically want to share.

According to the source code in `Global/VisualStudioCode.gitignore`, the standard pattern uses a single asterisk to match immediate children, then negates individual files:

```gitignore
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets

```

The trailing `/*` tells Git to ignore all files directly inside `.vscode`, while each `!` line creates an exception for specific configuration files. This prevents colleagues from receiving your local debug configurations or personal UI state while allowing shared tasks and extension recommendations to remain tracked.

## JetBrains IDEs: Ignoring the .idea Directory

For IntelliJ IDEA, PyCharm, WebStorm, and other JetBrains products, the `Global/JetBrains.gitignore` template targets the `.idea` directory with double-asterisk patterns to handle nested structures.

As implemented in `Global/JetBrains.gitignore`, the recommended rules ignore everything under `.idea` recursively, then selectively restore workspace files that are safe to version control:

```gitignore
.idea/**
!.idea/**/workspace.xml
!.idea/**/tasks.xml
!.idea/**/usage.statistics.xml
!.idea/**/dictionaries/**
!.idea/**/shelf/**

```

The `**` wildcard matches files at any depth within the directory tree, ensuring that subdirectories like `.idea/inspectionProfiles/` or `.idea/libraries/` are excluded. The negated lines preserve files containing run configurations and task contexts that define project-specific workflows rather than personal IDE state.

## Pattern Syntax: Single vs. Double Asterisk

Understanding the distinction between `*` and `**` helps you customize these templates effectively.

- **Single asterisk (`*`):** In `.vscode/*`, matches only files and folders immediately inside the directory. This is sufficient for flat configuration folders.
- **Double asterisk (`**`):** In `.idea/**`, matches across all subdirectories recursively. JetBrains IDEs nest configuration deeply, requiring this broader pattern.

The exclamation mark (`!`) negates a previous ignore rule. Git processes these rules sequentially, so the negation must appear after the broad ignore statement to have effect.

## Visual Studio Template Coverage

If your team uses Visual Studio alongside VS Code, note that the `VisualStudio.gitignore` template also contains the complete VS Code block described above. This makes it a comprehensive choice for Microsoft-centric development stacks, ensuring you do not need to maintain separate entries for both environments.

## Complete Project Template

Combine both IDE patterns in your root `.gitignore` to support mixed development environments. This implementation references the official `github/gitignore` templates directly:

```gitignore

# IDE-specific ignore rules from github/gitignore

# https://github.com/github/gitignore

# VS Code - keep shared settings, ignore local state

.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets

# JetBrains IDEs - keep workspace files, ignore user-specific data

.idea/**
!.idea/**/workspace.xml
!.idea/**/tasks.xml
!.idea/**/usage.statistics.xml
!.idea/**/dictionaries/**
!.idea/**/shelf/**

# Uncomment the line below if you track module definitions

# !*.iml

```

## Summary

- **Use `Global/VisualStudioCode.gitignore`** to ignore `.vscode` while preserving [`settings.json`](https://github.com/github/gitignore/blob/main/settings.json), [`tasks.json`](https://github.com/github/gitignore/blob/main/tasks.json), and [`launch.json`](https://github.com/github/gitignore/blob/main/launch.json) for team sharing.
- **Use `Global/JetBrains.gitignore`** to ignore `.idea` recursively while keeping [`workspace.xml`](https://github.com/github/gitignore/blob/main/workspace.xml) and [`tasks.xml`](https://github.com/github/gitignore/blob/main/tasks.xml) under version control.
- **Apply negation patterns** (`!`) after broad ignores to create exceptions for specific files.
- **Remove negated lines** entirely if you prefer to ignore all IDE files without exception, simplifying the rules to `.vscode/` or `.idea/`.

## Frequently Asked Questions

### What is the difference between `.vscode/*` and `.vscode/**`?

The pattern `.vscode/*` matches files only at the root of the `.vscode` directory, while `.vscode/**` matches files at any depth including subdirectories. According to the `github/gitignore` source, VS Code uses flat configuration files requiring only `*`, whereas JetBrains IDEs store settings in nested structures necessitating `**`.

### Should I commit [`.vscode/settings.json`](https://github.com/github/gitignore/blob/main/.vscode/settings.json) to Git?

Yes, typically you should commit [`settings.json`](https://github.com/github/gitignore/blob/main/settings.json) if it contains project-specific configurations like linting rules or formatting preferences that ensure consistency across your team. The `Global/VisualStudioCode.gitignore` template explicitly un-ignores this file because it defines shared workspace standards rather than personal IDE state.

### Where should I place IDE ignore rules in my project?

Place these rules in the root `.gitignore` file at the top level of your repository. The `github/gitignore` templates assume root-level placement when they specify paths like `.vscode/*` and `.idea/**`. If you place them in a subdirectory's `.gitignore`, you must adjust the paths to match the relative location.

### Why does the JetBrains template preserve [`workspace.xml`](https://github.com/github/gitignore/blob/main/workspace.xml) while ignoring most of `.idea`?

The [`workspace.xml`](https://github.com/github/gitignore/blob/main/workspace.xml) file in JetBrains IDEs contains run configurations and task contexts that define how the project executes—information valuable for sharing consistent debugging setups. However, the same directory contains user-specific caches and indices that cause noisy diffs. The `Global/JetBrains.gitignore` template balances these concerns by ignoring the directory recursively then explicitly restoring only the workflow-relevant XML files.