合并到一个特定的提交 [英] Merge up to a specific commit
问题描述
我在git的 master
分支中创建了一个名为 newbranch
的新分支。现在我已经完成了一些工作,并希望合并 newbranch
到 master
;不过,我对 newbranch
做了一些额外的修改,我想将 newbranch
合并到第四个-last提交给 master
。
我用 cherry-pick
但它显示消息使用正确的选项:
git checkout master
git cherry-pick ^^ ^^ HEAD newbranch
我可以使用git merge
做到这一点吗?
git merge newbranch< commitid>
当然,在 master
分支所有你需要做的是:
$ p $ g $ merge git merge commit-id>
其中 commit-id
最后一次从> newbranch
提交,您希望获得 master
分支。
您可以通过执行 I created a new branch named I used Can I use git
Sure, being in where You can find out more about any git command by doing 这篇关于合并到一个特定的提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! git help< command>
来了解关于任何git命令的更多信息。它的情况是 git help merge
。而且文档中说 merge 命令的最后一个参数是
< commit> ...
,所以你可以通过引用任何提交或甚至多个提交。虽然,我从来没有做过后者。 newbranch
from the master
branch in git. Now I have done some work and want to merge newbranch
to master
; however, I have made some extra changes to newbranch
and I want to merge newbranch
up to the fourth-from-the-last commit to master
.cherry-pick
but it shows the message to use the right options:git checkout master
git cherry-pick ^^^^HEAD newbranch
merge
to do it instead?git merge newbranch <commitid>
master
branch all you need to do is:git merge <commit-id>
commit-id
is hash of the last commit from newbranch
that you want to get in your master
branch.git help <command>
. It that case it's git help merge
. And docs are saying that the last argument for merge
command is <commit>...
, so you can pass reference to any commit or even multiple commits. Though, I never did the latter myself.