Find and Switch to a Branch by Partial Name

Search across local and remote branches for a pattern like "feat/mu" and jump onto it.

When to use

You remember part of a branch name (for example, feat/mu) but need a quick way to locate it and resume work.

Pre-flight

  • Your repository already has the branch in question locally or on a remote such as origin.
  • You have permission to fetch from the remote so the branch list is current.

Steps

  1. Refresh branch information so you do not miss recently pushed work.

    git fetch --all --prune
  2. Search for branches whose names include your fragment. Wildcards let you match patterns such as *feat/mu*.

    git branch --all --list '*feat/mu*'
  3. Switch to the branch once you spot the exact name.

    # Branch already exists locally
    git switch feat/mu
    
    # Branch only on the remote (creates local tracking branch)
    git switch --track origin/feat/mu

Verification

  • git status reports "On branch feat/mu" and shows the working tree state.
  • git branch --show-current echoes feat/mu.

Follow-up

  • Run git pull to grab any commits pushed after you last worked on the branch.
  • Use git switch - later if you need to hop back to the previous branch quickly.

Concept refresher

Need a deeper comparison of git switch, git checkout, and git restore? Read Choose Between git switch, git checkout, and git restore.