1
0
Fork 0
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%
Find a file
Paul 5e7f5cbf0d
feat(picker): group branches under sections; rebase on diverge (#46)
## 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
2026-05-08 14:14:21 +01:00
.github/workflows ci: update actions to latest major versions 2026-04-01 13:16:10 +01:00
completions feat: add shell tab completion for zsh, bash, and fish 2026-03-12 14:24:48 +00:00
src feat(picker): group branches under sections; rebase on diverge (#46) 2026-05-08 14:14:21 +01:00
tests feat(picker): group branches under sections; rebase on diverge (#46) 2026-05-08 14:14:21 +01:00
.gitignore feat: initial project scaffold 2026-03-12 12:18:57 +00:00
Cargo.lock feat(picker): group branches under sections; rebase on diverge (#46) 2026-05-08 14:14:21 +01:00
Cargo.toml feat(picker): group branches under sections; rebase on diverge (#46) 2026-05-08 14:14:21 +01:00
CLAUDE.md feat(just): add release recipe for version bumps and tagging 2026-04-09 14:51:03 +01:00
justfile fix(release): use portable perl for in-place version bump (#15) 2026-04-27 18:21:18 +01:00
README.md feat: add shell tab completion for zsh, bash, and fish 2026-03-12 14:24:48 +00:00
renovate.json fix(renovate): sync Cargo.lock on dependency updates 2026-04-01 14:14:51 +01:00

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

Requires Rust and just.

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