Home·Error messages

git · Git

The message

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

What it means

git found no file, branch or tag by that name — the string inside the quotes is exactly what it looked for. It happens on a typo, when the branch exists only on the server and you have not fetched, or when the file sits in a different directory than you assumed. For a branch, git fetch then git branch -a and compare the name by eye; for a file, git status --short shows the real paths. Remember that paths in git commands are read relative to the directory you are standing in, not the repository root, which alone accounts for many of these.

The fix

There is no one-line command for this. The explanation says what to look at instead.

Printed by
git
Git
29

Almost every git error is a refusal that means "doing that from this state would lose something"; fatal: means git stopped without changing anything, and the hint: lines under the first line usually carry the actual remedy.

Reading an error message

  • Read from the first line down. The lower you go the more it is about the tool’s internals; the cause is usually at the top.
  • If there is a file and a line number, start there — not the top stack frame, but the topmost line that names a file you wrote.
  • Search the message verbatim, but strip your own paths and variable names first; those are what stop the search from matching.
  • The same condition is worded differently across tool versions. If results look wrong, add the version number to the query.
  • Before pasting a fix, check what it throws away. Some of these cannot be undone.

Common questions

Q. What does “error: pathspec 'featue' did not match any file(s) known to git” mean?

git found no file, branch or tag by that name — the string inside the quotes is exactly what it looked for. It happens on a typo, when the branch exists only on the server and you have not fetched, or when the file sits in a different directory than you assumed. For a branch, git fetch then git branch -a and compare the name by eye; for a file, git status --short shows the real paths. Remember that paths in git commands are read relative to the directory you are standing in, not the repository root, which alone accounts for many of these.

Q. How do I fix it?

There is no one-line command. The explanation above says what to look at instead.

Q. Which tool prints this?

git. It sits under Git, and the message runs to 11 words.

Errors nearby