Skip to content
| Marketplace
Sign in
Visual Studio Code>SCM Providers>GitVeilNew to Visual Studio Code? Get it now.
GitVeil

GitVeil

breder.dev

|
1 install
| (0) | Free
Manage local Git filters (info/exclude, skip-worktree and assume-unchanged) from a sidebar, with protected Pull and Checkout operations.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

GitVeil

VS Code extension that keeps local changes to a Git repository outside the normal versioning flow, using three native Git mechanisms:

Mechanism Equivalent Git command Purpose
Exclude entries in .git/info/exclude Ignore untracked files (or patterns) on this machine only.
Skip Worktree git update-index --skip-worktree Make Git ignore local changes to a tracked file.
Assume Unchanged git update-index --assume-unchanged Used only for flags created earlier, for compatibility. No longer offered for new files (it is not reliable protection, see below).

The extension shows everything in a single view, Hidden Files, in the Activity Bar. You can enable or suspend filters without losing their configuration, and it offers protected Pull, Checkout and Switch Branch operations, which preserve local changes before the Git operation runs.


Contents

  1. Requirements
  2. Development
  3. Usage
  4. The three mechanisms
  5. Protected operations
  6. Settings
  7. Security guarantees
  8. Real API limitations
  9. Architecture
  10. Persistence
  11. Internationalization
  12. Tests and quality
  13. Packaging (.vsix), CI and release
  14. Not implemented

Requirements

  • VS Code 1.95 or later.
  • Git with support for stash push --pathspec-from-file (tested with Git 2.56). Older versions may lack this option; in that case the protected operations that use stash fail with Git's message, without changing any file.
  • Node.js 22 (development only).
  • pnpm 10.28 (the project's official package manager).
  • A trusted workspace (untrustedWorkspaces is not supported, because the extension runs Git and changes index flags).

Development

pnpm install --frozen-lockfile --engine-strict
pnpm run build          # compiles src/ to out/

To test in VS Code: open the project folder, run pnpm run build and press F5 (the Run Extension configuration). If you prefer the VS Code debug flow, create a launch.json pointing to the project folder.

Scripts

Script What it does
pnpm run lint ESLint with @mathbreder/eslint-config (flat config, eslint.config.mjs).
pnpm run lint:fix Applies the automatic fixes ESLint allows.
pnpm run typecheck tsc --noEmit with strict and extra type-safety options.
pnpm run test Vitest tests (unit, integration with real Git, and i18n).
pnpm run test:coverage Tests with a coverage report (coverage/).
pnpm run build Compiles to out/.
pnpm run check lint + typecheck + test + build. It is the gate required before any delivery.
pnpm run l10n:extract Extracts the vscode.l10n.t(...) messages to l10n/bundle.l10n.json.
pnpm run package Compiles and generates gitveil.vsix.

Usage

Sidebar

The GitVeil icon opens the container with a single view, Hidden Files. It lists the repositories and the hidden files in each one. You do not choose the mechanism: Hide file decides how to hide (see How GitVeil chooses). Each item shows an icon, the mechanism used and a state description:

State Meaning
Active (closed eye, green) Configured and applied in Git.
Suspended (pause, grey) Configured, but temporarily not applied. The configuration is kept.
Divergent (warning, yellow) The real state in Git does not match the configuration (for example, the flag was changed in the terminal). Refresh or re-enable.
Missing (X file, red) The file does not exist on disk.
Untracked (question mark, red) Skip Worktree and Assume Unchanged require a tracked file.
Error (red) The last attempt to apply the filter failed. The reason appears in the tooltip.
External (plug, purple) Flag or exclude line created outside GitVeil. It is informative only and is never removed by the extension.

When a managed file has local changes that Git cannot carry over to another branch, the view shows a warning under the repository: Switching to X would be blocked by local changes in: Y. The warning is computed from Git's state and does not intercept anything. It is refreshed when the window gains focus, when .git/index or .git/info/exclude changes (which covers most branch switches), and when you click Refresh. A content edit without an index change appears only after one of these actions.

With GitLens installed, each local branch listed in the GitLens view has a Switch branch with GitVeil button, which runs the protected switch without opening another picker. This integration reads GitLens' internal item structure, which is not a public API: if GitLens changes, the button shows an error instead of acting. Remote branches are not supported.

When a branch switch made by VS Code's built-in Git (SCM or command palette) fails and there are known blocks, GitVeil shows a notification with the Switch with GitVeil button, which runs the protected switch. Detection is by inference: VS Code does not report the error or the target branch, so GitVeil compares HEAD before and after the checkout. There are false positives, such as git checkout -- file or a checkout to the current branch, and false negatives after a switch made outside VS Code, until the next checkout. Switches made in the terminal are not detected.

In the view toolbar: Refresh, Hide file, Add exclude pattern, Reveal all files. On repositories: enable/suspend all filters, protected Pull, protected Checkout, protected Switch Branch and recover an interrupted operation. On items: enable/suspend, open file, reveal in Explorer, Reveal file and show status.

Context menus

Right-click a file or folder in the Explorer, the editor tab, the text editor or a file in Source Control. The GitVeil items appear directly in the menu, and only where they apply:

  • GitVeil: Hide file / GitVeil: Hide folder appear for paths that Git tracks or does not ignore. Paths already ignored by an external rule (.gitignore, .git/info/exclude, global ignore file) show no GitVeil option.
  • GitVeil: Reveal file / GitVeil: Reveal folder appear for paths that GitVeil manages, even when an external rule also covers them. Revealing never removes the external rule.

Multiple selection is supported. The repository that owns each file is identified automatically, including in multi-root workspaces and nested repositories.

Adding from the extension

The Hide file button lets you pick files or folders with the visual picker, or type a relative path with real-time validation. You do not need to choose the mechanism: GitVeil decides it (see below). Glob patterns are added with the Add exclude pattern button.

How GitVeil chooses

File situation What happens
Untracked Exclude (.git/info/exclude).
Tracked, no staged change Skip Worktree. Works with or without a content change.
Tracked, with a staged change Asks for confirmation to remove it from the index and only then applies Skip Worktree. The content does not change.
Already ignored by .gitignore Reports that it is already ignored and does nothing.
In a merge conflict Refuses, until the conflict is resolved.
Folder Exclude. Folders are accepted this way only; glob patterns use their own button.

Assume Unchanged is not part of this choice. It is still read and removed for earlier filters, but it is not offered for new files.

Reveal file and Reveal all files remove only the rule or flag that GitVeil created. No file content is changed.

If the repository is active, the filter is applied immediately. If it is suspended, the item is only recorded for the next activation.

The three mechanisms

Exclude (.git/info/exclude)

  • Writes a managed block delimited by markers; external lines and comments are preserved byte for byte.
  • Paths are anchored to the repository root and gitignore special characters are escaped.
  • Does not change .gitignore and does not add anything to the index.
  • Warning: Exclude does not ignore changes to files already under version control. Use Skip Worktree for that.
  • info/exclude is shared between worktrees of the same repository (Git's behavior). For that reason the block is the union of the filters of all registered worktrees.

Skip Worktree (git update-index --skip-worktree)

  • Applied only to tracked files. The extension checks this before applying.
  • The real state is read from git ls-files -v -z (letter S/s), not from git status.
  • Use it for versioned local settings you do not want to commit.

Assume Unchanged (git update-index --assume-unchanged) — legacy only

  • It is no longer chosen automatically. Filters created earlier are still read and removed normally.
  • Applied only to tracked files (letter h/s in ls-files -v).
  • It is an optimization hint for Git, not reliable protection. If the file is modified by Pull or Checkout, Git may overwrite it without warning. Prefer Skip Worktree to protect local changes.
  • Skip Worktree and Assume Unchanged are not interchangeable; each has its own flag, reading and removal.

Ownership of flags

The extension removes only the flags it created (ownsRestriction). If a flag was already active before the item was added, it is considered external: it is shown as External and is not removed when the item is deleted.

Protected operations

Protected Pull, Protected Checkout and Protected Switch Branch are in the Command Palette (GitVeil: …), in the view and in the extension's own menus. Before running, the extension checks:

  1. Whether an interrupted operation exists (pending journal) → blocks.
  2. Whether a merge, rebase, cherry-pick or revert is in progress → blocks.
  3. Whether there are unresolved conflicts → blocks.
  4. Relevant changes in the registered files: changes hidden by a flag (detected by comparing the disk content with the index blob, regardless of the flags), unstaged, staged, deleted locally, untracked, ignored, and unsaved editor changes.
  5. Staged changes in any file (including files not registered).

If nothing relevant is found, the operation runs directly. Otherwise, a dialog appears asking how to continue with the protected files that have local changes.

When a protected operation finds local changes in managed files, the extension uses stash automatically, without asking:

  • Writes a journal (.git/gitveil-transaction.json) before any change.
  • Releases only the flags of the files that have changes, remembering exactly which ones they were.
  • Creates a stash restricted to the registered files with --pathspec-from-file and NUL. The stash is identified by the transaction's unique marker, never by stash@{0}.
  • Untracked and ignored files are not part of the stash; they are copied to .git/gitveil/backups/<transaction>/ and verified by size.
  • Runs the operation and reapplies the stash. It uses stash apply --index only when there are staged changes, to preserve them; otherwise it applies without --index. Only then does it remove the stash.
  • Restores the flags exactly as they were.

It never uses reset --hard, checkout --force or clean to protect your changes.

Failures and recovery

  • Git operation failure: the extension reapplies the stash and restores the flags. The failure is shown with Git's reason.
  • Content conflict in a managed file: the local version prevails and the file stays hidden. The official version from the target branch stays in the index and HEAD, with no conflict markers and nothing added to the stage. An informational notification, which does not block the operation, lists the affected files. No action is needed.
  • Conflict that requires intervention (unmanaged file, file with a staged change, or a structural conflict such as a file that became a folder): the stash is kept and the extension shows a notification with two actions:
    • Resolve conflicts: opens the conflicting files. After resolving them and running git add, click Finish restoration: the stash is removed once the changes are applied.
    • Revert stash application: restores only the conflicting files to the official version (HEAD), without touching other files or the branch. A file you edited after the conflict is not reverted and is listed for manual resolution. The stash, flags and pending operation are kept. To reapply your local version, use Recover local content. Do not run git stash apply manually: with protected files, Git renames the file to <name>.stash.<id> and removes the flag.
  • VS Code interruption: on activation, the extension detects the journal and offers Recover. Recovery reapplies the stash (if it has not been restored yet), restores the flags and clears the journal. It asks for modal confirmation.
  • Divergent flag: if a GitVeil flag (Skip Worktree or Assume Unchanged) disappears from the index, for example through a change made outside the extension, the status shows divergent. When the view is refreshed, GitVeil reapplies the flag automatically. It does not reapply when the file has a staged change, when an operation is in progress or when a recovery is pending; in those cases the status stays divergent until the situation is resolved.
  • Stash could not be removed after successful restoration: the warning shows the error; the content has already been restored.
  • Pending recovery: while an interrupted transaction exists, the Hidden Files view shows a Pending recovery item for the repository, with the list of affected paths. The information comes from the journal (.git/gitveil-transaction.json) and survives a VS Code restart. Actions: Recover local content, Revert stash application and Open backup folder, when backups exist. Protected operations are blocked until recovery finishes. If a backup file was changed afterwards, the extension does not overwrite it: copy the content manually from the backup folder and then recover. Nothing is discarded without verifying that the content was restored.

Settings

Setting Default Effect
gitveil.enabled true When false, the view shows only the deactivation notice. The commands remain available.
gitveil.autoRefresh true Refreshes the view when the window gains focus and when .git/index or .git/info/exclude change.
gitveil.showNotifications true Shows informational notifications (errors are always shown).
gitveil.defaultFilterType exclude Mechanism preselected when adding files.
gitveil.restoreFiltersAfterOperation true After a successful protected operation, reapplies the repository configuration to fix divergences.
gitveil.showExternalFlags true Shows flags and exclude lines created outside GitVeil.

Interface preferences are global, but the state of each repository (active/suspended and items) is independent and stored in the repository itself.

Security guarantees

  • Never runs destructive commands without consent: no reset --hard, checkout --force or clean -fd.
  • Never stashes the whole project: the stash is always restricted to the registered paths with changes.
  • Never removes the stash before confirming the restoration.
  • Never treats a Git failure as success: exit codes are checked and stderr is preserved.
  • Git processes run without a shell (execFile with argv), which prevents command injection with file names containing spaces, accents or special characters.
  • Never changes files outside the selected repository. Paths that escape the root (.., absolute, inside .git) are rejected.
  • Persisted data and Git output are treated as untrusted input and validated. A corrupted record or journal raises an error and is not silently discarded, so that no data is lost.
  • Concurrent Git operations on the same repository are serialized within the extension.

Real API limitations

This section matters. Read it before relying on GitVeil as your main workflow.

  1. A checkout made outside GitVeil is not protected. The view's warning helps anticipate the block, but it does not prevent the switch. Protection for external checkouts (an adapter via git.path) is planned in issue #1, with a setting to turn it on or off.
  2. There is no public API to intercept native Git Pull, Checkout or Switch. The extension does not use monkey patching or override internal commands. Therefore, operations run from the native Pull button, the terminal, another extension or Git's own UI do not go through the protection. To have protection, use the GitVeil: Protected Pull / Checkout / Switch Branch commands.
  3. Items in the Git menus (Source Control) are limited. The SCM resource menu is used for the submenu commands, but the extension cannot add entries inside the native Git menu.
  4. Context menus depend on the state the extension can compute, not on live Git checks. VS Code only evaluates when clauses against context keys published by the extension. GitVeil publishes the list of paths Git tracks or does not ignore, and the list of paths it manages, and refreshes them on index, exclude and .gitignore changes, on branch switches and on view refresh. A rule change made in a way GitVeil does not watch (for example, a global ignore file outside the workspace) can leave the menu out of date until the next refresh. The commands still check the real Git state before acting, so a stale menu does not change files.
  5. Assume Unchanged is not protection and is no longer offered for new files. This is a limitation of Git itself: Git may overwrite the file during Pull or Checkout.
  6. info/exclude is shared between worktrees. A pattern registered in one worktree also appears in the others, because Git uses the same file. Paths are anchored, but the effect is shared. The extension keeps the union of all worktrees so it does not erase another worktree's entries.
  7. Concurrency between VS Code windows. Serialization happens inside one instance of the extension. Two windows operating on the same repository at the same time are not coordinated by a file lock.
  8. stash push --pathspec-from-file. It depends on a Git version that supports the option. The exact minimum version has not been verified; the project was tested only with Git 2.56.
  9. Ignored and untracked files are not stashed. They are protected by a backup copy verified by size, not by automatic restoration. The backup lives in .git/gitveil/backups/ and is never deleted by the extension.
  10. Git operations can be refused. When there are protected changes, the extension uses stash; if Git itself refuses the operation, the extension shows the error and restores everything, without bypassing the refusal.
  11. Permissions on Windows. Permission errors are detected from Git's messages (Permission denied, Access is denied). There is no automated test simulating permissions, because chmod does not apply to Windows.
  12. Content conflicts in managed files are resolved in favor of the local version. This is a deliberate choice, so that local customization does not block a branch switch or get revealed by conflict markers. The consequence is that the remote change does not appear in the worktree while the file is hidden. It remains available in the index and HEAD. The notification lists the files where the local version prevailed: check them against the target branch if its changes matter, because the merge is not done in the worktree.
  13. Renames that take a file out of a hidden folder are reported. The warning shows the old and new path. The file is visible at the new path and must be hidden again if needed.
  14. Symbolic links and Sparse Checkout have not been tested. The extension's behavior with symlinks and sparse checkout is not verified by automated tests.
  15. CRLF line endings are preserved byte for byte with core.autocrlf=false and core.autocrlf=true, in the conflict cases tested.

Architecture

The extension follows Clean Architecture, with the dependency rule pointing inward:

src/
├── domain/            # entities, value objects, rules and state machine (no vscode, Node or Git)
├── application/       # use cases, ports (interfaces) and orchestration services
│   ├── ports/         # GitInspectionPort, GitMutationPort, RegistryPort, JournalPort, ...
│   ├── services/      # FilterEnforcer, RepositoryStore, ProtectionAssessor, RepositoryLock, ...
│   └── usecases/      # AddFilter, RemoveFilter, ProtectedOperation, RecoverTransaction, ...
├── infrastructure/    # adapters: Git CLI, JSON persistence, info/exclude, backups, clock/ids
├── composition/       # composition root (createServices): wires adapters and use cases
├── presentation/      # TreeView, commands, dialogs, notifications, i18n (the only layer that imports vscode)
└── extension.ts       # activation: connects presentation and composition

Relevant design points:

  • Pure domain: FilterTarget, FilterEntry, RepositoryFilters, Transaction and RelativePath are discriminated, immutable types. States such as FilterStatus and Transaction.stage are validated by a transition table.
  • Small ports (ISP): Git querying, Git mutation, registry, journal, exclude file, file system and user decisions are separate interfaces.
  • Presentation does not decide rules: commands resolve targets from the arguments (Uri, SourceControlResourceState, TreeView nodes, multi-selection arrays) and delegate to use cases.
  • Composition without a DI framework: createServices wires everything through constructors. Integration tests use the same composition with real adapters.
  • Error messages are typed codes (UseCaseFailureCode). The message map is a typed Record, so a new code without a translation does not compile.

Persistence

Data Location Shared between worktrees?
Filter registry (repositories, entries, mechanism, suspension, ownership) <git-common-dir>/gitveil/registry.json Yes (one file per repository)
Managed block of the exclude file <git-common-dir>/info/exclude Yes (Git's behavior)
Journal of an in-progress protected operation <git-dir>/gitveil-transaction.json No (per worktree)
Backups of untracked/ignored files <git-dir>/gitveil/backups/<transaction>/ No
Index flags each worktree's index No

Persistence lives inside .git, so it survives restarts, closing and reopening projects, branch switches and window reloads. Writes are atomic (temporary file + rename).

Divergences between the registry and the real Git state are detected on every refresh and shown as Divergent. The extension does not overwrite external changes automatically.

Internationalization

  • Code messages use vscode.l10n.t(...) with literals (required for extraction).
  • Manifest: package.nls.json (English, base) and package.nls.pt-br.json.
  • Extension messages: l10n/bundle.l10n.json (English, base) and l10n/bundle.l10n.pt-br.json.
  • The language is detected automatically by VS Code; English is the fallback.

Tests in tests/i18n/localization.test.ts verify:

  • that pt-br has exactly the same keys as the base;
  • that the placeholders {0}, {1}… are the same in the translation;
  • that every vscode.l10n.t('…') call in the source exists in the bundle (the check uses the TypeScript API, not regex);
  • that every %key% in package.json exists in both manifest files;
  • that a text identical to English appears only for technical terms explicitly listed.

To add a language: copy bundle.l10n.pt-br.json and package.nls.pt-br.json with the new language suffix and translate them. No business logic changes.

Tests and quality

pnpm run test
Suite Files What it covers
Domain unit tests tests/unit/domain/ Path normalization, exclude escaping, derived status, aggregate invariants, transaction state machine, directory split, menu candidate rules.
Infrastructure unit tests tests/unit/infrastructure/ Decoding of the ls-files -v letters (H, S, h, s), status/stash/worktree parsers, validation of corrupted registry and journal.
Presentation unit tests tests/unit/presentation/ Menu target resolution (Uri, SCM, arrays), owning repository with nesting, TreeView grouping, folder-first ordering, placeholder for fully hidden folders.
Integration (real Git) tests/integration/filters.integration.test.ts The three mechanisms in temporary repositories; exclude preserving external lines; suspension and resumption; external flags; flag ownership; paths with spaces, accents and globs; persistence across instances; worktrees.
Integration (real Git) tests/integration/protected-operations.integration.test.ts Pull without changes (no stash); restricted stash with flag restoration; staged and unstaged preserved on checkout; operation failure with full restoration; conflict on reapplication with stash kept; cancellation; "continue without stash" with confirmation; merge in progress; backup of untracked files; dirty editor; recovery of an interrupted transaction; protected branch switch.
Reapplication of divergent flags (real Git) tests/integration/reapply-divergent.integration.test.ts Reapplication of Skip Worktree and Assume Unchanged after external flag removal; staged file not hidden; suspended entries and disabled repository ignored; pending transaction; idempotence.
Conflict recovery (real Git) tests/integration/conflict-recovery.integration.test.ts Per-path revert with fingerprint, refusal after a later edit, reapplication, conflict markers, injected failures (restoration, flags, stash removal) with recovery on the second attempt, idempotence, user stash preserved, pending backup, persistence after restart, isolation between repositories.
Revealing inside a hidden folder (real Git) tests/integration/reveal-within-directory.integration.test.ts Splitting a hidden folder into children when a file is revealed, and re-hiding it.
Menu candidates (real Git) tests/integration/menu-candidates.integration.test.ts Candidate list across nested .gitignore, info/exclude, core.excludesFile, ignored directories and negations, tracked files matching a pattern, third-party flags, branch switches, worktrees and multiple repositories.
i18n tests/i18n/localization.test.ts Integrity of translations and manifests.

Integration tests create real Git repositories and remotes in temporary directories and remove them at the end. They require git on the PATH.

Current coverage: pnpm run test:coverage generates the report. The src/extension.ts layer is excluded. The presentation layer (TreeView and commands) has no automated Extension Host test, because that requires downloading VS Code. It has not been validated in VS Code by an automated test, so the visual behavior of the menus, the tree and the placeholder should be checked manually.

Mandatory gate before any delivery: pnpm run check.

Packaging (.vsix), CI and release

pnpm run package     # generates gitveil.vsix (the project has no runtime dependencies)

.vscodeignore includes out/, l10n/, package.nls*.json and media/, and excludes sources, tests, configs and pnpm-lock.yaml.

The extension is published as brederdev.gitveil under the MIT license (see LICENSE). The package.json declares "private": true to prevent accidental publication to npm.

Workflows:

  • .github/workflows/ci.yml runs on every push to main and on every pull request: install with --frozen-lockfile --engine-strict, lint, typecheck, i18n tests, full tests and build.
  • .github/workflows/release.yml runs when a tag vX.Y.Z is pushed. It runs the quality gate, packages the .vsix, checks that the tag matches the package.json version, publishes to the VS Marketplace with the VSCE_PAT secret, and only then creates the GitHub Release with the .vsix attached.

To publish a new version: update version in package.json, commit, and push a tag with the same number.

Not implemented

  • Bulk actions per group (enable/suspend all items of a mechanism). The action is optional in the requirement; today it exists per repository and per item.
  • Integration with the native Git menu (API limitation, see above).
  • Extension Host tests (they require downloading VS Code).
  • Automated tests for permission failures (not reliably reproducible on Windows).
  • Tests for a file removed after being added and for multiple repositories in the same workspace. The logic exists, but there is no dedicated integration test for these two scenarios.
  • Coordination between VS Code windows (see limitations).
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft