GitSweep.Cli
1.2.0
dotnet tool install --global GitSweep.Cli --version 1.2.0
dotnet new tool-manifest
dotnet tool install --local GitSweep.Cli --version 1.2.0
#tool dotnet:?package=GitSweep.Cli&version=1.2.0
nuke :add-package GitSweep.Cli --version 1.2.0
GitSweep
GitSweep is an interactive .NET CLI for finding and cleaning local Git branches that are already merged or stale. It uses Spectre.Console for a colorful TUI with scan summaries, candidate tables, confirmation prompts, progress bars, and readable error messages.
Requirements
- .NET 10 SDK for local development
- Git available on the command line
Install
dotnet tool install --global GitSweep.Cli
Or install the npm wrapper:
npm install --global @stescobedo9205/gitsweep-cli
Update an existing install:
dotnet tool update --global GitSweep.Cli
npm update --global @stescobedo9205/gitsweep-cli
Quick Start
# Analyze the current repository, then choose branches interactively.
gitsweep
# Same command through the explicit subcommand.
gitsweep clean
# Preview candidates without deleting anything.
gitsweep clean --dry-run
Usage Examples
# Analyze another repository and consider branches stale after 3 months.
gitsweep clean -p C:/code/my-repo -a 3
# Show only branches already merged into the default branch.
gitsweep clean -p C:/code/my-repo --merged-only
# Show only stale branches older than 12 months.
gitsweep clean -p C:/code/my-repo --stale-only --age 12
# Automation-friendly cleanup: select all merged branches and skip confirmation.
gitsweep clean --merged-only --all --yes
# Preview what an automation run would delete.
gitsweep clean --stale-only --age 6 --all --dry-run
# Use a relative path and default stale age.
gitsweep clean -p ../other-repo
Options
| Option | Description |
|---|---|
-p, --path |
Repository path. Defaults to the current directory. |
-a, --age |
Months after which a branch is stale. Defaults to 6. |
--dry-run |
Show candidates without deleting branches. |
--merged-only |
Only include branches merged into the target branch. |
--stale-only |
Only include stale branches. |
--all |
Select every listed candidate without opening the picker. |
-y, --yes |
Skip final confirmation. Must be used with --all. |
How It Works
GitSweep.Clihosts the Spectre.Console CLI and interactive TUI.GitSweep.Coreowns contracts and models such asBranchInfo,IBranchAnalyzer, andIGitRepositoryService.GitSweep.Infrastructureruns Git commands and keeps command-line process details out of the UI layer.- Merged branches are detected with
git branch --merged <target>. - Stale branches are branches whose last commit is older than the configured age and are not already classified as merged.
GitSweep deletes branches with safe local deletes (git branch -d). If Git refuses because a branch is not fully merged, GitSweep reports the failure and leaves the branch intact.
Development
dotnet restore
dotnet build
dotnet test
dotnet run --project GitSweep.Cli -- clean --dry-run
Pack the CLI tool locally:
dotnet pack GitSweep.Cli/GitSweep.Cli.csproj -c Release -p:Version=0.0.0-local
Releases
Releases are automated with Release Please and Conventional Commits:
fix:creates a patch release.feat:creates a minor release.feat!:orBREAKING CHANGE:creates a major release.
When changes land on master, GitHub Actions calculates the next SemVer, packs GitSweep.Cli as a .NET tool, publishes it to nuget.org, publishes @stescobedo9205/gitsweep-cli to npm, and creates the GitHub release. The workflow currently uses the NUGET_ORG_NEW_API_KEY secret for both registry publishes.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
This package has no dependencies.