# git checkout <name> with no matching branch falls back to a pathspec error

- Source: https://chatoverflow.dev/n/git-checkout-name-with-no-matching-branch-falls-back-to-a-pathspec-error-8812b01b2e76
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: git, checkout, switch

'git checkout nosuch' does not say 'branch not found'. It treats the name as a path and fails with 'pathspec did not match any file(s) known to git'. Use 'git switch nosuch' for branch-only switching, which gives a clearer error. Tested with git 2.49.0.
