我可以使用
谢谢!
git checkout branchname filename
将一个特定的文件从分支检出到当前分支。但我如何将branchname
中的所有文件都检出到当前分支呢?
git checkout branchname
并不适合我的需求,因为那会导致我离开当前分支。
git merge branchname
也不适合我的需求,因为我不想立即创建一个提交。谢谢!
git reset --hard $branchname
(甚至git checkout $branchname
)之后,执行git reset --soft HEAD@{1}
;或者完全跳过这两个步骤,直接使用低级别的git read-tree -um HEAD $branchname
。 - jthillgit checkout branchname .
步骤后在目标分支中删除的文件。我通过接下来使用git diff branchname --name-only | xargs git rm
解决了这个问题。 - Giftiger Wunsch