![](/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.