error: pathspec 'x' did not match any file(s) known to git
Git couldn’t find the file or branch name you referenced.
Seen on:
Git
Meaning
Typos, branch names that only exist on the remote (not fetched yet), paths relative to the wrong directory, or case mismatches.
Common causes
- Branch not fetched yet
- Typo or wrong case
- Path relative to a different directory
- Commit message without -m quotes (words treated as paths)
⚡ Quick fix
- git fetch then git switch <branch>
- Check names with git branch -a / git ls-files
- Quote commit messages: git commit -m "message"
Detailed fix by platform
Git
git fetch origin && git switch feature/login
How to diagnose
- Name — Branch or path?
- Remote — Fetched?
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026