GIT 02 -git rebase -i 用法

vim 中批量替换字符
命令行模式下:%s/[from-word]/[to-word]/

修改提交历史纪录

git rebase -i
图中红色区域即用来修改提交历史纪录的命令
这里写图片描述
提交记录中上面的是父提交,下面最近的提交

拆分提交记录
关键字:edit
用法:
更改子提交 pick 为edit,表示需要修改此次提交;然后reset到需要拆分的上次提交,但是保留工区的内容,再依次commit工作区中的内容;
git reset HEAD^
git add thirdA.txt
git commit -sm “this is thirdA commit ”
git add thirdB.txt
git commit -sm “this is thirdB commit ”
git rebase –continue

拆分后的提交记录
这里写图片描述

合并提交记录
关键字:squash
用法:
更改子提交 pick 为squash,表示与当前提交的父提交合并;
这里写图片描述
历史纪录前后对比
这里写图片描述

本次将两个提交合并为新的提交记录
afe15c36f72b9202060d9a068a3392a627d3abbf this is five commit T
15900665e3e154966a86ef75879ef91e3de45d07 this is four commit T

批量修改历史提交信息
关键字:reword
用法:
更改子提交 pick 为reword,表示修改历史提交信息;
这里写图片描述

修改历史记录前
这里写图片描述

修改历史记录后
这里写图片描述

删除历史纪录

修改pick为drop, 或者
直接删除所在的行

git rebase -i 用法说明

# Rebase b769e18..756b5d9 onto b769e18 (5 command(s))
#
# 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
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值