Git Diagnostic

Fix "error: pathspec 'branch-name' did not match any file(s) known to git"

Occurs when running git checkout <name> or git switch <name> for a branch that does not exist locally and has not yet been fetched from the remote tracking origin.

error: pathspec did not match any file(s) known to git

Quick Fix Checklist

  1. Fetch all latest remote branches: git fetch --all --prune
  2. Verify branch exists on remote: git branch -r
  3. Checkout remote tracking branch: git switch <branch-name>
  4. If creating a brand new local branch: git checkout -b <branch-name>