pathspec did not match 🌿 Git

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

  1. git fetch then git switch <branch>
  2. Check names with git branch -a / git ls-files
  3. Quote commit messages: git commit -m "message"

Detailed fix by platform

Git

  1. git fetch origin && git switch feature/login

How to diagnose

  1. Name — Branch or path?
  2. 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.