Skip to content

switch

Move between branches without leaving your hierarchy. git city switch is pure navigation: it checks out another branch (and nothing else), either by name or through an interactive fuzzy picker.

git city switch [name]

It is a validated git checkout — it confirms the target exists, then switches to it. It does not fetch, rebase, push, or move any commits, so it is safe to run as often as you like.


Switching by name

Pass the branch you want and git-city checks it out:

git city switch add-login

If the branch does not exist, you get a clean error instead of a raw Git failure:

git-city: unknown branch: add-login

The interactive picker

Run switch with no name on a terminal and git-city opens an interactive fuzzy picker listing every branch except the one you are already on. Type to filter, use the arrow keys to move, and press Enter to switch.

git city switch

The picker only works on a TTY. With no name in a non-interactive context (a script, a pipe, CI), there is nothing to pick from, so git-city reports an error:

git-city: switch needs a branch name when not interactive

Give a name in scripts

The fuzzy picker is a convenience for the terminal. In automation, always pass an explicit branch name so the command never depends on a prompt.


What switch does not do

switch is deliberately minimal, and that shapes how it behaves.

Property switch
Moves commits No — it only checks out a ref
Touches your working files No, beyond the checkout itself
Requires a clean working tree No
Records run-state No
Is undoable No

Because it moves no commits and touches no lineage metadata, switch does not refuse on a dirty working tree the way the commit-moving commands (new, sync, land, delete, insert, squash) do.

Not part of the undo history

switch does not write run-state, so git city undo will not reverse it — undo always targets the last commit-moving operation, not your navigation. To go back, just switch again.


See where you are

After switching, the dashboard and the tree both mark your current branch, so you always know where you landed.

Run git city info for the full dashboard:

git-city · my-project
  trunk:  main
  remote: origin

on  ● add-login   (feature, parent: main)
    working tree: clean
    vs main:  ↑2 ↓0
    vs origin/add-login:  ↑0 ↓0

stack:
main  (trunk)
└─ ● add-login  ↑2 ↓0

Or git city tree for just the hierarchy, with the current branch marked by a filled dot:

main  (trunk)
└─ api  ↑3 ↓0
   └─ ● ui  ↑2 ↓0

Commands overview


  • Commands overview — the full command list.
  • The mental model — trunks, features, and the parent hierarchy you are navigating.
  • recoveryundo, continue, and abort for the commands that do move commits.