如果我想用另一个分支中相同的文件夹替换工作分支上的文件夹,我可以执行以下命令:
git checkout OTHER_BRANCH -- /path/to/folder
什么是 -- 的含义?
如果我想用另一个分支中相同的文件夹替换工作分支上的文件夹,我可以执行以下命令:
git checkout OTHER_BRANCH -- /path/to/folder
--
后面的所有内容都被认为是文件名。这在至少两种情况下很有用:
git checkout foo --
和git checkout -- foo
之间的区别。git checkout -- -f
(或者: git checkout ./-f
)