当前位置:   article > 正文

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

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

git rebase -i 的使用

git rebase -i 的使用

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

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

git commit --amend -s
git rebase --continue
  • 1
  • 2

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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

第一步:执行 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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23

第二步:將上面内容的一行 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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

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

root@root: git commit --amend file1.c file2.c
root@root: git rebase --continue
Successfully rebased and updated refs/heads/master.
  • 1
  • 2
  • 3
git format-patch -18
git am *.patch
  • 1
  • 2
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/喵喵爱编程/article/detail/1012260
推荐阅读
相关标签
  

闽ICP备14008679号