Skip to content

queiio/git-sweep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

git-sweep

A tiny CLI that finds local Git branches whose remote-tracking branch is gone — typically because the corresponding PR was merged and the remote branch was deleted — and removes them in one shot.

Install

From source:

git clone https://github.com/<you>/git-sweep
cd git-sweep
pip install -e .

Usage

git-sweep                    # dry-run: lists what would be deleted
git-sweep --delete           # actually delete them
git-sweep --delete --force   # use `git branch -D` (also deletes unmerged)
git-sweep --no-prune         # skip `git remote prune` first
git-sweep --remote upstream  # prune a different remote

By default, git-sweep runs git remote prune origin so that remote refs are up to date, then lists every local branch whose upstream is marked [gone].

Example

$ git-sweep
found 3 stale branch(es):
    fix/login-redirect (was origin/fix/login-redirect)
    feat/user-prefs (was origin/feat/user-prefs)
  * release/0.4 (was origin/release/0.4)

dry-run. pass --delete to actually remove them.

The * marker means the branch is currently checked out — it will be skipped on delete, since Git refuses to delete the checked-out branch.

Why

After a few months of feature work, local repos collect dozens of dead branches. git branch -d <name> for each one is annoying. This automates the obvious bulk case while staying conservative: dry-run by default, never delete the current branch, never touch a branch that still tracks a live remote.

Requirements

  • Python 3.10+
  • Git on PATH

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages