mirror of
https://github.com/brzzdev/git-switch.git
synced 2026-05-16 17:40:26 +00:00
Interactive Git branch switcher with merged branch cleanup
- Rust 95.7%
- Just 3.7%
- Shell 0.6%
## Summary - Group branches in the picker under **Pinned**, **Local**, and **Remote** headings, with a sticky heading and per-section availability indicators (`☁`, `(missing)`). - When fast-forward fails because local commits diverged from the remote, prompt to rebase onto the remote-tracking branch instead of just printing guidance. Aborts cleanly on conflict so the working tree returns to its prior state. - Replace `Pick`'s boolean `remote_only` / `missing` flags with an `Availability` enum, and split `MergeResult` into `MergeReport` + `FastForwardResult` to model the two distinct outcomes. - Pre-lower the fuzzy-match needle once per filter pass instead of once per item. - New tests cover pinned-branch ordering/dedup and the rebase clean/aborted outcomes. ## Test plan - [x] `just test` — 20 tests pass - [x] Manual: switch to a branch that fast-forwards cleanly - [x] Manual: switch to a branch where local has diverged from remote and confirm the rebase prompt - [x] Manual: decline the rebase prompt and confirm the guidance message - [x] Manual: trigger a rebase conflict and confirm the working tree is restored - [x] Manual: run picker with `git-switch.keep` config to verify Pinned section ordering |
||
|---|---|---|
| .github/workflows | ||
| completions | ||
| src | ||
| tests | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| CLAUDE.md | ||
| justfile | ||
| README.md | ||
| renovate.json | ||
git-switch
A fast, interactive Git branch switcher. Pick a branch, fetch & fast-forward it, and clean up merged branches — all in one step.
Features
- Interactive branch picker — fuzzy-select from local branches (or pass a name directly)
- Auto-stash — dirty working tree? Changes are stashed before switching and restored after
- Fast-forward pull — fetches from origin and fast-forward merges, warns if the branch has diverged
- Merged branch cleanup — prompts to delete local branches that have been merged into the current branch
Install
git clone https://github.com/brzzdev/git-switch.git
cd git-switch
just install
This builds a release binary and copies it to ~/.local/bin/git-switch. Make sure ~/.local/bin is on your PATH.
Usage
# Interactive — pick a branch from a list
git-switch
# Direct — switch to a specific branch
git-switch main
Shell Completions
Tab completions are available for zsh, bash, and fish.
just install-completions
This installs the appropriate completion script for your current shell. For zsh, make sure ~/.zsh/completions is in your fpath before compinit:
fpath=(~/.zsh/completions $fpath)
autoload -Uz compinit && compinit
Configuration
Protect branches from the "delete merged branches" prompt by adding them to your Git config:
git config --add git-switch.keep develop
git config --add git-switch.keep staging
License
MIT