Git:将多个提交从一个分支合并到另一个分支 [英] Git : Merge multiple commits from one branch into another

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

问题描述

我有以下用例。


  1. 我有一个主线分支。从主线的分支(dev)。

  2. dev 分支提交多个提交(大约20) / strong>(远程)分支。

现在我想将所有这20个提交合并到一个提交中,强>主线即可。如何做到这一点?



在此先感谢,

Shantanu

解决方案

听起来像是一个 git merge --squash

  git checkout mainline 
git merge --squash dev
git commit

请注意,如在这里评论,最好先在 dev 中合并 mainline 并解决那里的冲突。在 mainline 中合并 dev


I have following use case.

  1. I have a mainline branch.
  2. Created new branch(dev) from mainline.
  3. Did multiple commits(around 20) into dev branch and pushed into dev(remote) branch as well.

Now I want to merge all these 20 commits into single commit and move this to mainline. How exactly I can do this?

Thanks in Advance,
Shantanu

解决方案

That sounds like a git merge --squash

git checkout mainline
git merge --squash dev
git commit

Note that, as commented here, it is best to merge mainline in dev first and solve any conflict there, before merging back dev in mainline.

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

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