执行git合并时可以排除特定的提交吗? [英] Is it possible to exclude specific commits when doing a git merge?

查看:198
本文介绍了执行git合并时可以排除特定的提交吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我想从发布分支合并到主分支,并且发布分支中有一些提交,我不想将其包含在主分支中。有没有办法进行合并,以便这些提交中的一个或多个不会被合并?



到目前为止,我的策略是执行以下操作(在master中):

  git merge --no-commit release-branch 
#解决冲突并应用提交的反向修补程序不希望包含
git commit#编辑提交消息,以便它列出已反向修补的提交

有没有更好的方法来做到这一点?

解决方案

创建一个新分支, drop提交你不想要的,然后合并。



你不能在没有重新哈希的情况下从分支中间取出更改,但会发生正确的事情当它在后面的合并中看到相同的变化时(例如,从樱桃采摘和不采用什么)。


Let's say that I want to merge from a release branch to the master branch and there are some commits in the release branch that I don't want to include in the master branch. Is there a way to do the merge so that one or more of those commits will not be merged?

My strategy so far is to do the following (in master):

git merge --no-commit release-branch
# Resolve conflicts and apply reverse patch of the commits that I don't want included
git commit # Edit commit message so that it lists the commits that have been reverse-patched

Is there a better way to do this?

解决方案

Create a new branch, rebase the branch interactively and drop commits you don't want, and then merge that.

You can't take changes out of the middle of a branch without rehashing, but the right thing will happen when it sees the same changes in a later merge (e.g. from cherry-picking and what-not).

这篇关于执行git合并时可以排除特定的提交吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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