赞
踩
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
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。