$ pwd
/sandbox/views/projectOne/Messages/src
$ git branch
bugfix/F1
feature/F2
* feature/F3
master
$ git checkout feature/F2 -- Messages/src/*.cpp
error: pathspec 'Messages/src/*.cpp' did not match any file(s) known to git.
$ git checkout feature/F2 -- Messages/src/Hello.h
error: pathspec 'Messages/src/Hello.h' did not match any file(s) known to git.
$ git checkout feature/F2 -- /Messages/src/Hello.h
fatal: Could not switch to '/Messages/': No such file or directory
$ git checkout feature/F2 /Messages/src/Hello.h
fatal: Could not switch to '/Messages/': No such file or directory
$ git checkout feature/F2 Messages/src/Hello.h
error: pathspec 'Messages/src/Hello.h' did not match any file(s) known to git.
Early, I am able to use the following command without issues:
$ git checkout master -- Messages/src/Hello.h
How can I fix the issue?
Judging by this:
pwd /sandbox/views/projectOne/Messages/src
I'm guessing that you are not in the project root but inside src/Messages
.
Try this way:
git checkout feature/F2 -- Hello.h
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.