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.