A small, cross-platform Go CLI that removes local branches whose upstream has been removed (e.g., branches marked as "[gone]"). Safe by default, dry-run first, and designed for Windows/macOS/Linux.
Linux / macOS
curl -fsSL https://raw.githubusercontent.com/jmelosegui/git-sweep/main/scripts/install.sh | bashPass -s -- --prerelease to opt into the latest pre-release tag:
curl -fsSL https://raw.githubusercontent.com/jmelosegui/git-sweep/main/scripts/install.sh | bash -s -- --prereleaseThe script installs to ~/.git-sweep/bin (override with INSTALL_DIR=...) and adds that directory to your shell rc (bash, zsh, fish, or ~/.profile as a fallback). Reload your shell or source the rc file afterwards.
Windows (PowerShell)
irm https://raw.githubusercontent.com/jmelosegui/git-sweep/main/scripts/install.ps1 | iexFor pre-releases, run the script with the -Prerelease switch:
& ([scriptblock]::Create((irm https://raw.githubusercontent.com/jmelosegui/git-sweep/main/scripts/install.ps1))) -PrereleaseThe script installs to %LOCALAPPDATA%\git-sweep (override with $env:GIT_SWEEP_INSTALL_DIR) and updates your user Path. Restart your terminal afterwards.
- Go to the repository Releases page and pick a version. To use a pre-release, select a tag labeled “Pre-release”.
- Download the archive matching your OS/arch:
- linux:
git-sweep_<version>_linux_amd64.tar.gz(or_arm64) - macOS:
git-sweep_<version>_darwin_amd64.tar.gz(or_arm64) - Windows:
git-sweep_<version>_windows_amd64.zip(or_arm64)
- linux:
- (Recommended) Verify checksum:
- Download
checksums.txtfrom the same release - macOS/Linux:
# Replace <version>, <os>, and <arch> with the actual values for your downloaded file. # Example for version 1.2.3 on Linux amd64: shasum -a 256 -c checksums.txt | grep git-sweep_1.2.3_linux_amd64 # Or, for your specific file: shasum -a 256 -c checksums.txt | grep git-sweep_<version>_<os>_<arch> - Windows PowerShell:
Get-FileHash .\git-sweep_<version>_windows_amd64.zip -Algorithm SHA256 # Compare against the corresponding line in checksums.txt
- Download
- Extract:
- macOS/Linux:
tar -xzf git-sweep_<version>_<os>_<arch>.tar.gz
- Windows PowerShell:
Expand-Archive .\git-sweep_<version>_windows_amd64.zip -DestinationPath .\git-sweep
- macOS/Linux:
- Move the binary into your PATH:
- macOS/Linux (example):
sudo mv git-sweep /usr/local/bin/
- Windows (example): add the extracted folder to the "Path" user environment variable, or move
git-sweep.exeinto a directory already on PATH.
- macOS/Linux (example):
- Verify:
git sweep -V
Dry-run (default):
git sweepExecute deletions (interactive confirm if TTY):
git sweep -yJSON plan output:
git sweep --jsongit-sweep checks the GitHub Releases API at most once every 24 hours and prints a one-line notice on stderr when a newer version is available. The check is skipped automatically when --json is set, when stderr is not a terminal (CI, redirects), and for the development build. To opt out entirely, set GIT_SWEEP_NO_UPDATE_CHECK=1.
