Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Add to Gitignore ButtonNew to Visual Studio Code? Get it now.
Add to Gitignore Button

Add to Gitignore Button

VastBlast

|
3 installs
| (1) | Free
Add files and folders to the appropriate .gitignore from the Explorer context menu.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Add to Gitignore Button

Adds selected files and folders to the applicable .gitignore from the VS Code Explorer context menu.

Install

Install from the Visual Studio Marketplace

Or install from the command line:

code --install-extension VastBlast.vastblast-add-to-gitignore

Behavior

  • Right-click one or more files or folders in Explorer and run Add to .gitignore.
  • Uses the nearest existing .gitignore that can ignore the selected item.
  • Creates a repository-root .gitignore when none exists.
  • Falls back to the workspace-root .gitignore when the workspace is not inside a Git repository.
  • Writes anchored patterns with forward slashes, escaped glob characters, escaped whitespace, and trailing slashes for directories.
  • Avoids duplicate exact patterns and preserves existing line endings.

Development

npm run compile
npm run lint
npm test
npm run package

The tests cover POSIX paths, Windows paths, nested .gitignore files, repositories above the opened workspace folder, duplicate selections, line endings, escaping, and invalid paths.

Run npm run test:vscode only when you need to launch the full VS Code extension test host. In WSL, that requires the VS Code/Electron native Linux libraries to be installed.

Publishing

npm run package
npm run publish

The extension is published from https://github.com/VastBlast/vscode-add-to-gitignore-button under the VastBlast publisher.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft