A CLI tool to quickly switch between recent git branches with an interactive TUI
npm install gbswitchA simple and intuitive CLI tool to quickly switch between your recent Git branches using an interactive TUI.
- Shows the 5 most recently committed-to branches
- Interactive terminal UI with arrow key navigation
- Displays relative time since last commit on each branch
- Automatically excludes the current branch from the list
- Handles uncommitted changes with stash option
- Color-coded output for better visibility
``bash`
npm install -g gbswitch
Simply run the command from any Git repository:
`bash`
gbswitch
1. Run gbswitch in any Git repository
2. The tool will display your 5 most recent branches (excluding current)
3. Use ↑/↓ arrow keys to navigate through the list
4. Press Enter to checkout the selected branch
5. Press Esc or select "Cancel" to exit without switching
- Automatic stashing: If you have uncommitted changes, the tool will prompt you to stash them before switching
- Time display: Shows how long ago each branch was last committed to
- Current branch display: Shows your current branch at the top for reference
Add a shorter alias for quick access:
Add to ~/.bashrc:
`bash`
alias gb="gbswitch"
Add to ~/.zshrc:
`bash`
alias gb="gbswitch"
Run once or add to ~/.config/fish/config.fish:
`fish`
alias gb="gbswitch"
Or create a persistent abbreviation:
`fish`
abbr -a gb gbswitch
Add to your PowerShell profile ($PROFILE):
`powershell`
Set-Alias -Name gb -Value gbswitch
After adding the alias, restart your terminal or reload your config:
`bashBash/Zsh
source ~/.bashrc # or ~/.zshrc
- Node.js (v12 or higher)
- Git
MIT