Git rebase合并多个提交
本文介绍了通过 Git 命令操作,文末有 Goland IDEA 的简便操作。
查看日志,找到需要合并的多个分支的上一个起点,比如 18a14636
$git log --oneline
d1503601 feat(link_video):埋点统计
ad94a443 feat(bottom_ecmp_policy):策略名称唯一验证修复
043fa7de feat(bottom_ecmp_policy):策略名称唯一验证修复
32fae648 feat(bottom_ecmp_policy):策略名称唯一验证
80cee6b4 feat(bottom_ecmp_policy):按ecpm正序排序
f955a20e feat(bottom_ecmp_policy):新增策略类型'动态adload-底部cpm'
18a14636 (tag: v7.3.9.3) Merge branch 'release/v7.3.9.3'
使用 rebase 进行合并
进入编辑器后,把除了第一行的 pick
全部改成 squash
, :wq
保存。重新编辑一下提交日志,再次 :wq
即可。
$git rebase -i 18a14636
pick feat(link_video):埋点统计
pick feat(bottom_ecmp_policy):策略名称唯一验证修复
pick feat(bottom_ecmp_policy):策略名称唯一验证修复
pick feat(bottom_ecmp_policy):策略名称唯一验证
pick feat(bottom_ecmp_policy):按ecpm正序排序
pick feat(bottom_ecmp_policy):新增策略类型'动态adload-底部cpm'
#
# Commands:
# p, pick <commit> = use commit
# r, reword <commit> = use commit, but edit the commit message
# e, edit <commit> = use commit, but stop for amending
# s, squash <commit> = use commit, but meld into previous commit
# f, fixup [-C | -c] <commit> = like "squash" but keep only the previous
# commit's log message, unless -C is used, in which case
# keep only this commit's message; -c is same as -C but
# opens the editor
# x, exec <command> = run command (the rest of the line) using shell
# b, break = stop here (continue rebase later with 'git rebase --continue')
# d, drop <commit> = remove commit
# l, label <label> = label current HEAD with a name
# t, reset <label> = reset HEAD to a label
# m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]
# . create a merge commit using the original merge commit's
# . message (or the oneline, if no original merge commit was
# . specified); use -c <commit> to reword the commit message
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
Goland Git
选择历史,选择多个提交,右键,squash commits