我如何在git中恢复提交? [英] How do I backport a commit in git?

查看:79
本文介绍了我如何在git中恢复提交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我的项目中有一个维护分支和一个主分支。如果我在维护分支中进行提交并且想将它合并到主分支,那很简单:

  git checkout master ; git合并维护

但是如果我想以相反的方式进行操作,回到我的维修部门,我该怎么做?这是否被认为是樱桃采摘?如果我将维护分支再次向前合并,它会导致问题还是冲突吗? 这正是 git-cherry-pick

  git checkout maintenance 
git cherry-pick <从主提交>


So, I have a maintenance branch and a master branch in my project. If I make a commit in the maintenance branch and want to merge it forward to the master branch, that's easy:

git checkout master; git merge maintenance

But if I want to go the other way around, i.e. apply a commit made to master back to my maintenance branch, how do I do that? Is this considered cherry-picking? Will it cause problems or conflicts if I merge the maintenance branch forward again?

解决方案

This is exactly the use case for git-cherry-pick

git checkout maintenance
git cherry-pick <commit from master>

这篇关于我如何在git中恢复提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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