![](/img/trans.png)
[英]How to checkout files from another branch and then overwrite the current branch
[英]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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.