You must be specifying the wrong commit or the wrong path.
$ git init
Initialized empty Git repository in /.../.git/
$ echo test.txt > .gitignore
$ git add .gitignore
[master (root-commit) 6ed8815] Commit 1
1 file changed, 1 insertion(+)
create mode 100644 .gitignore
$ git commit -m "Commit 1"
$ echo 'Version 1' > test.txt
$ git add test.txt
The following paths are ignored by one of your .gitignore files:
test.txt
Use -f if you really want to add them.
fatal: no files added
$ git add -f test.txt
$ git commit -m "Commit 2"
[master b23a130] Commit 2
1 file changed, 1 insertion(+)
create mode 100644 test.txt
$ echo 'Version 2' > test.txt
$ git add test.txt
$ git commit -m "Commit 3"
[master 60c1f24] Commit 3
1 file changed, 1 insertion(+), 1 deletion(-)
$ cat test.txt
Version 2
$ git checkout b23a130 test.txt
$ cat test.txt
Version 1
If I type in the wrong commit, I get this error message:
$ git checkout 6ed8815 test.txt
error: pathspec 'test.txt' did not match any file(s) known to git.
I also get the error message if I type the wrong pathname:
$ git checkout b23a130 other.txt
error: pathspec 'other.txt' did not match any file(s) known to git.