A powerful terminal-based (TUI) Git branch management tool that provides an interactive interface for managing Git branches with rich visual feedback and advanced features.
- Interactive TUI: Navigate branches with arrow keys in a clean, professional interface
- Branch Operations: Checkout, delete, rename, and create branches with ease
- Visual Indicators:
*Current branch↓Remote branches[modified]Uncommitted changes[unpushed]Local branches not on remote[merged]Branches merged into main/master[worktree]Branches in other worktrees
- Smart Stash Management:
- Automatic prompt to stash changes when switching branches
- Track and recover stashes with 'S' key
- Branch-specific stash detection
- Remote Branch Support: Toggle viewing and checkout remote branches
- Branch Protection: Extra confirmation for deleting main/master branches
- Worktree Support: Shows worktree indicators and prevents conflicts
- Powerful Filtering:
- Search by name (
/) - Filter by author (
a) - Hide old branches (
o) - Hide merged branches (
m) - Filter by prefix (
p)
- Search by name (
- Smart Sorting: Branches sorted by most recent commits
- Color Coding: Age-based coloring for quick visual scanning
- Browser Integration: Open branches in GitHub, GitLab, Bitbucket, etc.
- Performance Optimized: Progressive loading with caching for instant startup, even in large repos
- Professional UI: Nano-style footer with command shortcuts
- Python 3.6+
- Git
- Terminal with color support
# Download and install to /usr/local/bin (requires sudo)
sudo curl -L https://raw.githubusercontent.com/daveschumaker/gbm/main/git-branch-manager.py -o /usr/local/bin/git-bm
sudo chmod +x /usr/local/bin/git-bm
# Or install to ~/.local/bin (no sudo required)
mkdir -p ~/.local/bin
curl -L https://raw.githubusercontent.com/daveschumaker/gbm/main/git-branch-manager.py -o ~/.local/bin/git-bm
chmod +x ~/.local/bin/git-bm
# Add ~/.local/bin to PATH if not already present
# For bash: echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc && source ~/.bashrc
# For zsh: echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc && source ~/.zshrc
# Now you can run from anywhere
git-bm
# Or as a git alias
git config --global alias.bm '!git-bm'
git bm # Now works as a git subcommand!# Clone the repository
git clone https://github.com/daveschumaker/gbm.git
cd gbm
# Make executable
chmod +x git-branch-manager.py
# Option 1: Run directly
./git-branch-manager.py
# Option 2: Create symlink (recommended)
ln -s $(pwd)/git-branch-manager.py ~/.local/bin/git-bm
# Now you can run from anywhere
git-bm# Add as git alias
git config --global alias.bm '!python3 /path/to/git-branch-manager.py'
# Now use as:
git bm# Show version
gbm --version
gbm -v
# Show help
gbm --help
gbm -h
# Specify a different git repository directory
gbm --directory /path/to/repo
gbm -d /path/to/repo↑/↓orj/k: Navigate through branchesPage Up/Page Down: Navigate by pageHome/End: Jump to first/last branchEnter: Checkout selected branchqorESC: Quit (ESC also clears filters)
D: Delete selected branch (with confirmation)M: Move/rename branchN: Create new branch from currentS: Pop last stash (if available)
/: Search branches by namea: Toggle author filter (show only your branches)o: Toggle old branches filter (>3 months)m: Toggle merged branches filterp: Filter by prefix (feature/, bugfix/, etc.)c: Clear all filters
t: Toggle remote branches viewf: Fetch from remoteb: Open branch in browserB: Open branch comparison/PR pager: Reload branch list
?: Show help screen
Git Branch Manager supports configuration via ~/.config/git-branch-manager/config.json:
{
"platform": "auto", // auto-detect or: github, gitlab, bitbucket-cloud, bitbucket-server, custom
"default_base_branch": "main", // default branch for comparisons
"browser_command": "open", // command to open browser (open on macOS, xdg-open on Linux)
"prevent_browser_for_merged": false, // prevent opening browser for merged branches (useful if remote deletes merged branches)
"custom_patterns": { // for custom Git hosting platforms
"branch": "https://git.example.com/{repo}/tree/{branch}",
"compare": "https://git.example.com/{repo}/compare/{base}...{branch}"
}
}The tool automatically detects your Git hosting platform:
- GitHub
- GitLab
- Bitbucket (Cloud & Server)
- Azure DevOps
- Custom platforms (via configuration)
*Current branch (highlighted in green)↓Remote branchLocal branch
[modified]: Has uncommitted changes[unpushed]: Exists locally but not on remote[merged]: Has been merged into main/master[worktree]: Checked out in another worktree
- Green: Current branch
- Cyan: Branch names
- Yellow: Modified indicator
- Magenta: Recent branches (<1 week)
- Blue: Commit info
- Red: Old branches (>1 month)
| Key | Action | Context |
|---|---|---|
↑/↓ |
Navigate branches | Always |
j/k |
Navigate branches (Vim-style) | Always |
PgUp/PgDn |
Navigate by page | Always |
Home/End |
Jump to first/last | Always |
Enter |
Checkout branch | Branch selected |
D |
Delete branch | Local branch selected |
M |
Move/rename branch | Branch selected |
N |
New branch | Always |
S |
Pop stash | Stash available |
/ |
Search | Always |
a |
Author filter | Always |
o |
Old branches filter | Always |
m |
Merged filter | Always |
p |
Prefix filter | Always |
c |
Clear filters | Filters active |
t |
Toggle remotes | Always |
f |
Fetch | Always |
r |
Reload | Always |
b |
Open in browser | Branch selected |
B |
Compare/PR | Branch selected |
? |
Help | Always |
q |
Quit | Always |
ESC |
Clear filters/Quit | Always |
# Start branch manager
gbm
# Press 't' to see remote branches
# Press '/' to search for a feature
# Press Enter to checkout
# Press 'N' to create new branch
# Press 'D' to delete old branchesgbm
# Press 'o' to hide old branches
# Press 'm' to hide merged branches
# Review remaining branches
# Press 'D' on branches to deletegbm
# Press 'a' to show only your branches
# Navigate and manage your work- Quick Filter Clear: Press
ESCto clear all filters at once - Safe Stashing: The tool remembers stashes it creates and shows them in the header
- Worktree Safety: Can't checkout branches that are active in other worktrees
- Protected Branches: Main and master branches require extra confirmation to delete
- Remote Checkout: Select a remote branch and press Enter to create a local tracking branch
- Quick Browser: Press 'b' to instantly view a branch on GitHub/GitLab/etc.
-
"No branches found"
- Ensure you're in a Git repository
- Try pressing 'f' to fetch from remote
-
Colors not showing
- Ensure your terminal supports colors
- Try setting
TERM=xterm-256color
-
Can't delete remote branches
- This is by design - only local branches can be deleted
- To remove remote branches, use standard git commands
-
Spinner not animating during fetch
- Requires Python threading support
- Check Python installation
Contributions are welcome! Please feel free to submit a Pull Request.
# Clone your fork
git clone https://github.com/yourusername/git-branch-manager.git
cd git-branch-manager
# Create a branch
git checkout -b feature/your-feature
# Make changes and test
python3 git-branch-manager.py
# Submit PRMIT License - see LICENSE file for details
- Inspired by interactive Git tools like lazygit and gitui
- Built with Python's curses library
- UI design influenced by nano and micro editors
Note: This tool is designed for local branch management. For advanced Git operations, please use the standard Git CLI.

