git:将另一个分支中的文件签出到当前分支(不要将HEAD切换到其他分支) [英] git: checkout files from another branch into current branch (don't switch HEAD to the other branch)
问题描述
我想将另一个分支中存在的文件的不同版本加载到我当前的分支中。
git help checkout
说:
说明
更新工作树中的文件以匹配索引中的版本或
指定的树。如果没有给出路径,那么git checkout也将$ b $ b更新HEAD以将指定的分支设置为当前分支。
是否有办法检出所有这些文件,但 not update HEAD ?
。
p> git checkout other-branch-name - 。
此操作与将HEAD切换到另一个分支而不检出文件类似,但只是从其他方向。
正如@김민준提到的,这会覆盖所有未提交的更改。请记住如果需要,先将它们存储或提交到某处。
I want to load a different version of the files that exist in another branch into my current branch.
git help checkout
says:
DESCRIPTION
Updates files in the working tree to match the version in the index or
the specified tree. If no paths are given, git checkout will also
update HEAD to set the specified branch as the current branch.
Is there a way to checkout all those files, but not update HEAD?
checkout by providing the current path, .
:
git checkout other-branch-name -- .
This operation is similar to switching HEAD to another branch without checking out files, but just from the "other direction".
As @김민준 mentions, this overwrites any uncommitted changes. Remember to either stash or commit them somewhere first if needed.
这篇关于git:将另一个分支中的文件签出到当前分支(不要将HEAD切换到其他分支)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!