无法从另一个本地分支签出文件
Fail to checkout files from another local branch
$ 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.
早期,我可以毫无问题地使用以下命令:
$ git checkout master -- Messages/src/Hello.h
我该如何解决这个问题?
据此判断:
pwd /sandbox/views/projectOne/Messages/src
我猜你不在项目根目录中,而是在 src/Messages
中。
试试这个方法:
git checkout feature/F2 -- Hello.h
$ 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.
早期,我可以毫无问题地使用以下命令:
$ git checkout master -- Messages/src/Hello.h
我该如何解决这个问题?
据此判断:
pwd /sandbox/views/projectOne/Messages/src
我猜你不在项目根目录中,而是在 src/Messages
中。
试试这个方法:
git checkout feature/F2 -- Hello.h