【嵌入式开发 Linux 常用命令系列 4.6 -- git rebase -i 的使用】

git rebase -i 的使用

git rebase -i 的使用

git rebase -i change_id(目标patch的前一个change_id)

对应的 comment 改成 edit 模式, 重新修改 patch(修改甚至可以是git reset --hard HEAD^:也即去除该patch)

git commit --amend -s
git rebase --continue

git log 之後如下显示,这个时候如果想修改 test2.c 这个文件。

git log
commit 25db05a5dab80237a72bf4df3122fe17f27b56e6 (HEAD -> master)
new: test:test3.c

commit eaffc8a491e8e1a44bc4375caf489ab31a39ff6a
new: test:test2.c

commit 5e9690990bc707ad4269e931761563494cbea290 (origin/master, m/master)
new: test:test1.c

第一步:执行 git rebase -i change_id 如下:

git rebase -i 5e9690990bc707ad4269e931761563494cbea290

pick eaffc8a49 NEW: Profile: add udp profile
pick 25db05a5d NEW: UDP: add header files for udp version

# Rebase 5e9690990..25db05a5d onto 5e9690990 (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

第二步:將上面内容的一行 pick 修改为 edit,然后 wq 退出,会输出下面提示信息:

Stopped at eaffc8a49...  NEW: Profile: add udp profile
You can amend the commit now, with

  git commit --amend

Once you are satisfied with your changes, run

  git rebase --continue

第三步:修改需要修改的文件, 然后提交:

root@root: git commit --amend file1.c file2.c
root@root: git rebase --continue
Successfully rebased and updated refs/heads/master.
git format-patch -18
git am *.patch
  • 4
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

主公CodingCos

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值