A Rust implementation of FuzzyBranch - a git tool that simplifies branch checkout by allowing partial branch name matching.
Instead of typing the complete branch name:
$ git checkout feature/really-long-branch-nameYou can use just enough characters to uniquely identify it:
$ git co realThe tool supports:
- Default branch checkout: Running with no arguments checks out the default branch (e.g. main or master)
- Exact matching: If the input exactly matches a branch name
- Substring matching: If the input is contained in one or more branch names
- Silent operation: No output on successful single match (only git's own output)
- Colored highlighting: Matched substrings are highlighted in green when showing ambiguous matches
- Commit checkout: Falls back to checking out commits if no branch matches
- Smart branch tracking: Shows local branches and remote-only branches without duplicates
- Build the project:
cargo build --release- Copy the executable to a directory in your
$PATH:
cp target/release/git-fuzzy ~/.local/bin/
# or
cp target/release/git-fuzzy /usr/local/bin/- Add a git alias to your
~/.gitconfig:
[alias]
co = !git-fuzzyAfter installation, use the git co alias (or run git-fuzzy directly):
# Get help
$ git-fuzzy --help
$ git-fuzzy --version
# With no arguments, checkout the default branch (e.g. main or master)
$ git co
Switched to branch 'main'
# Checkout a branch with substring matching (silent on success)
$ git co dev
Switched to branch 'develop'
# Checkout with partial name (silent on success)
$ git co real
Switched to branch 'feature/really-long-branch-name'
# Ambiguous matches show all options with highlighted match
$ git co feat
Ambiguous branch name 'feat'. Multiple matches:
feature/another-feature # 'feat' is highlighted in green
feature/really-long-branch-name
# Fall back to commit checkout if no branch matches
$ git co 620a729
No branches match '620a729', trying as commit...
HEAD is now at 620a729 initial commit- Branch Discovery: Retrieves all local branches and remote branches using
git for-each-ref - Smart Filtering: Shows local branches plus remote-only branches (avoiding duplicates)
- Fuzzy Matching:
- First tries exact match
- Falls back to substring match if no exact match found
- If no branch matches, attempts to checkout as a commit
- Checkout: Executes
git checkoutwith the matched branch or commit
- Rust 1.70 or later (for building)
- Git (for running)
This is a Rust reimplementation of the original Haskell FuzzyBranch by Wilfred Hughes.