git - Git:使用多个单引用合并模拟章鱼合并
问题描述
我知道我可以使用 触发章鱼合并git merge ref1 ref2
,但是否也可以使用多个命令获得相同的结果,例如
git merge --no-commit ref1
git merge --no-commit --magic-option ref2
git commit
或之后
git merge ref1
git merge ref2
将最后 2 个合并提交变成 1 个章鱼合并提交?
解决方案
您可以进行单独的合并,然后使用git commit-tree
...so.. 创建一个新的合并修订版,如下所示:
git checkout --detach brancha # so that the branch doesn't move
git merge branchb -m "Whatever"
git merge branchc -m "Whatever again"
# now we do our magic
git checkout $( git commit-tree -m "Here's the octopus merge" -p brancha -p branchb -p branchc HEAD^{tree} )
# last command creates a new revision with brancha branchb and branchc as parents, will hold the tree of the last merge.. and we check it out
# if you like it, you can move any of the branches and then check it out
git branch -f brancha
git checkout brancha
推荐阅读
- azure - 哪个 Azure 区域离我最近?
- kendo-ui - 如果剑道 UI 网格模板中的条件
- javascript - Socket.emit 仅在重新加载页面后有效
- sql-server - 随着时间的推移,SQL Server 对 GETDATE() 的结果是否有任何一致性?
- web-scraping - python抓取谷歌,获取requests.Response obj未知编码,无法读取任何内容所有内容都已加密
- bert-language-model - “AssertionError:您应该为此方法提供编码或编码列表
- git - git:具有新提交的压缩+合并分支的类似rebase的选项?
- jquery - jQuery .attr('数据顺序', sum); 不适用于父 div
- sql - 在 UNION 之后合并具有相同 ID 的 SQL 行
- sql - 对表使用看起来随机的 ID 而不是 PRIMARY KEY AUTOINCREMENT,以避免客户端知道记录数