Skip to content
| Marketplace
Sign in
Visual Studio Code>SCM Providers>Safe Branch SquashNew to Visual Studio Code? Get it now.
Safe Branch Squash

Safe Branch Squash

wen gong

| (0) | Free
Safely preview commits before squashing a feature branch
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Safe Branch Squash

Safe Branch Squash previews and safely combines the local commits on a feature branch into one commit.

Current capabilities

The extension can:

  • detect the Git repository for the active editor or workspace;
  • let you choose a repository when a workspace contains several;
  • suggest configured, remote-default, and common base branches;
  • calculate the merge base with HEAD;
  • display the commits that would be squashed;
  • block protected branches, dirty worktrees, shallow clones, and active Git operations;
  • create a verified Git bundle backup outside the visible branch graph;
  • create one equivalent commit without changing the index or working tree;
  • verify tree equality before and after atomically updating the branch;
  • optionally update the upstream branch with an exact force-with-lease.

It never pushes without an explicit Squash and Safe Push confirmation.

Usage

  1. Open a Git repository in VS Code.
  2. Run Git: Preview Current Branch Squash from the Command Palette.
  3. Select the branch your current feature branch started from.
  4. Review the ordered commit list.

To perform the local squash:

  1. Commit or stash all working tree changes.
  2. Hover the Source Control view title and click the Combine button, or run Git: Squash Current Branch into One Commit from the Command Palette.
  3. Select the base branch and review the commit list.
  4. Choose Continue with Squash.
  5. Enter the new commit message.
  6. Choose Squash Locally or Squash and Safe Push in the final confirmation.

The success message includes the backup bundle path. The bundle preserves the original commits without adding another branch to the Git graph.

Settings

  • safeBranchSquash.baseRef: preferred base branch for the current workspace, such as origin/main.
  • safeBranchSquash.protectedBranches: branch names that cannot be rewritten. The defaults include main, master, develop, stage, and staging.

Development

Run npm run compile, press F5, and execute the commands in the Extension Development Host window. Use a disposable repository when testing write flows.

Safety notes

The squash commit is created with git commit-tree, so normal pre-commit and commit-msg hooks are not run. The current branch is updated with an expected old HEAD value, preventing an unexpected concurrent branch change from being overwritten. Safe push fetches the upstream first and uses its exact object ID as the lease, so a concurrent remote update causes the push to fail.

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