Skip to main content
gx switch provides an interactive branch picker with search filtering, sorted by most recently committed. Each branch shows its age and author for quick context.

Usage

gx switch [- | branch]

Arguments

ArgumentDescription
-Switch to the previous branch (like git switch -)
branchSwitch directly to a named branch
(none)Open the interactive picker

Interactive Picker

When run without arguments, gx lists all branches (excluding the current one) sorted by most recent commit:
    1  feature/auth           5 minutes ago   Kim
    2  feature/dashboard      2 hours ago     James
    3  fix/login-redirect     3 days ago      Kim
    4  chore/deps             1 week ago      Alex

Enter a number to switch, text to filter, q to cancel
  • Enter a number to switch to that branch
  • Type text to filter branches by name (case-insensitive substring match)
  • Enter q or press Enter with no input to cancel
If there is only one other branch, gx switches to it automatically without showing the picker.

Quick Switch

The - shortcut switches to the previous branch, just like git switch -:
$ gx switch -
OK Switched to feature/auth

Examples

# Interactive picker
$ gx switch

# Switch to previous branch
$ gx switch -

# Direct switch (no picker)
$ gx switch feature/auth
If you have uncommitted changes, gx prints a warning before showing the picker: WARN You have uncommitted changes. They may conflict with the target branch.
  • If there are no other branches, gx prints > No other branches to switch to.
  • Branch names longer than 45 characters are truncated with ... in the picker display
  • The picker supports repeated filtering — entering new text replaces the previous filter
  • If gx switch - has no previous branch (new repo), gx prints ERROR No previous branch to switch to.