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
- Fetch all latest remote branches: git fetch --all --prune
- Verify branch exists on remote: git branch -r
- Checkout remote tracking branch: git switch <branch-name>
- If creating a brand new local branch: git checkout -b <branch-name>