合并到一个特定的提交 [英] Merge up to a specific commit

查看:99
本文介绍了合并到一个特定的提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在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 分支。



您可以通过执行 git help< command> 来了解关于任何git命令的更多信息。它的情况是 git help merge 。而且文档中说 merge 命令的最后一个参数是< commit> ... ,所以你可以通过引用任何提交或甚至多个提交。虽然,我从来没有做过后者。

I created a new branch named 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.

I used cherry-pick but it shows the message to use the right options:

git checkout master    
git cherry-pick ^^^^HEAD newbranch

Can I use git merge to do it instead?

git merge newbranch <commitid>

解决方案

Sure, being in master branch all you need to do is:

git merge <commit-id>

where commit-id is hash of the last commit from newbranch that you want to get in your master branch.

You can find out more about any git command by doing 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.

这篇关于合并到一个特定的提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆