【git】git rebase 合并几个commit

适用于你的分支落后目标分支很多的时候,看起来清爽点
合并多个commit
修改commit message内容

基础指令介绍

git 合并几个commit

git log --oneline 一条一条查看git日志
git rebase -i HEAD~n n为数字,可以合并多条commit,修改commit内容
进入vim编辑页面后 按i就是insert 就可以根据上面的提示修改
修改好之后按esc 再按:wq保存退出

git rebase --continue 继续下一个rebase
git rebase --abort 取消rebase合并
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
# d, drop = remove commit
# 命令:
# p, pick <提交> = 使用提交
# r, reword <提交> = 使用提交,但编辑提交说明
# e, edit <提交> = 使用提交,但停止以便在 shell 中修补提交
# s, squash <提交> = 使用提交,但挤压到前一个提交
# f, fixup [-C | -c] <提交> = 类似于 "squash",但只保留前一个提交
#                    的提交说明,除非使用了 -C 参数,此情况下则只
#                    保留本提交说明。使用 -c 和 -C 类似,但会打开
#                    编辑器修改提交说明
# x, exec <命令> = 使用 shell 运行命令(此行剩余部分)
# b, break = 在此处停止(使用 'git rebase --continue' 继续变基)
# d, drop <提交> = 删除提交
# l, label <label> = 为当前 HEAD 打上标记
# t, reset <label> = 重置 HEAD 到该标记
# m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]
# .       创建一个合并提交,并使用原始的合并提交说明(如果没有指定
# .       原始提交,使用注释部分的 oneline 作为提交说明)。使用
# .       -c <提交> 可以编辑提交说明。
#
# 可以对这些行重新排序,将从上至下执行。
#
# 如果您在这里删除一行,对应的提交将会丢失。
#
# 然而,如果您删除全部内容,变基操作将会终止。
git log --oneline 

在这里插入图片描述
git rebase -i HEAD~2
在这里插入图片描述
s squash = use commit, but meld into previous commit

使用提交,但融入之前的提交
在这里插入图片描述

git push

合并多次提交

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

修改commit message

1.    git rebase -i  HEAD~1 
2.    键盘输入insert【i】(键盘按键i) 将pick改为e/edit ,esc(键盘按键),: wq (保存并退出)
3.  git commit --amend --message="thinker change message"
4. git rebase --continue
5. git push

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值