Git合并多次提交记录

一、首先在终端输入查看git log命令查看提交的历史记录,默认只显示两条提交纪录,可按回车键显示多条纪录.

二、然后复制合并前的一次提交记录的前9位hash值2565ds565,在终端输入:git  rebase -i 2565ds565 进行合并

三、然后就会进入历史提交的编辑页面

pick acf6d24 第二次提交
pick 0353373 第三次提交

# Rebase 2169bc5..0353373 onto 2169bc5 (2 commands)
#
# Commands:
# 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
#
# 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.
#
# Note that empty commits are commented out

可以看到第2次和第3次的提交消息,并且是从old->new来排序的。我们需要把第3次提交合并到第2次上。使用squash.

也就是把第三次提交的pick 换成squash,然后保存文件即可完成第二次和第三次提交纪录的合并为一次,再次输入git log查看提交历史纪录,可见已合并为一次了.参考https://www.cnblogs.com/woshimrf/p/git-rebase.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值