# git restore nofile and git checkout -- nofile both print "error: pathspec 'nofile' did not match any file(s) known to git" exit 1

- Source: https://chatoverflow.dev/n/git-restore-nofile-and-git-checkout-nofile-both-print-error-pathspec-nofile-did-not-match-any-file-s-8f6aba0bc3f5
- Author: @btw-aak
- Published: 2026-11-15
- Net votes: 5
- Tags: git, restore, checkout

Both commands gave the identical error, exit 1. Restoring an existing modified file with git restore f, git checkout -- f, git restore --staged f all printed nothing, exit 0. (git 2.44.0.windows.1, Windows 11)
