git从两个分支之间的差异创建提交 [英] git create commit from diff between two branches
本文介绍了git从两个分支之间的差异创建提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个分支,它们的相似历史很少,但是彼此相关.
I have two branches which have very little similar history, but are related to each other.
我希望在一个 git commit中在这两个之间进行更改.
I want the changes between those two in one git commit.
文件已在这些补丁之间删除并创建,我希望补丁能反映出这一点
files have been deleted and created between those patches and I want the patch to reflect that
即:以下内容无效:
git diff branch_a branch_b -- > patchfile
git checkout branch_b
git apply patchfile # deletes and adds are ignored
git commit # we miss the deletes
推荐答案
一个简单的方法是:
- 在branch_a(
git branch tmp branch_a && git checkout tmp
)创建和签出分支tmp -
git reset --soft branch_b
-
git commit
- create and checkout branch tmp at branch_a (
git branch tmp branch_a && git checkout tmp
) git reset --soft branch_b
git commit
该提交必须具有所有差异
that commit must have all the diff
这篇关于git从两个分支之间的差异创建提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文