永久免费做网站app,建筑企业资质公司,凡科建站登录入口,deal 网站要怎么做0. 前言
今天在移植最新版本 kfence 功能的时候#xff0c;一共需要移植大概40多个 patch#xff0c;中间有很多patch 存在冲突#xff0c;需要手动修改后才能合并。当所有的patch 都合并完成进行编译的时候#xff0c;发现其中一个 patch 手动合并出了个错误。
假如共有…0. 前言
今天在移植最新版本 kfence 功能的时候一共需要移植大概40多个 patch中间有很多patch 存在冲突需要手动修改后才能合并。当所有的patch 都合并完成进行编译的时候发现其中一个 patch 手动合并出了个错误。
假如共有 40 个 patch编号 1 - 40现在问题是第 20 个patch 需要再修改一下而 21 - 40 的patch 有很多手动修改的怎么能快速有效的在不 reset 的基础上修改第 20 个patch呢
这就是本文需要说明的 git rebase命令。 1. git rebase -i HEAD~n
先来看下 option -i
-i
--interactive
Make a list of the commits which are about to be rebased. Let the user edit that list before rebasing. This mode can also be used to split commits (see SPLITTING COMMITS below).The commit list format can be changed by setting the configuration option rebase.instructionFormat. A customized instruction format will automatically have the long commit hash prepended to the format.See also INCOMPATIBLE OPTIONS below.
通过该选项产生一个将要 rebase 的commit list可以让用户在 rebase 之前进入交互的模式。
HEAD~n会列出从 HEAD 开始的倒数 n commit list例如 n 4 时 当执行 git rebase -i HEAD~4 命令就会弹出从 HEAD 开始的倒数 4 个 commit list最后一个是 HEAD commit。 当将第一行 commit即倒数第 4 个 commit 的命令从 pick 改成 edit 时则代码rebase 停在这个 commit用以 amend 处理。 当保存修改并退出交互之后就会发现倒数第 4 个commit 进入stop 状态等待 amend。 剩下来就简单了
修改代码git addgit commit --amendgit rebase --continue 2. 交互中的命令 在交互的窗口中除了之前说的 edit 命令本文也补充说下其他的命令
p/pick保持 commitr/reword保留commit但是需要修改 commit messagee/edit保留 commit但这里需要停下来等到 amends/squash保留commit但会将该 commit 合并到前一个 commit 中f/fixup类似 squash但是不会保留 commit messagex/exec等于在 shell 中运行命令d/drop丢弃该 commit 官方文档
https://git-scm.com/docs/git-rebase/