pick c37146f d pick 3d06118 修改commit b # Rebase f18b622..3d06118 onto f18b622 (2 commands) # # Commands: # p, pick <commit> = use commit # r, reword <commit> = use commit, but edit the commit message # e, edit <commit> = use commit, but stop for amending # s, squash <commit> = use commit, but meld into previous commit# f, fixup <commit> = like "squash", but discard this commit's log message # x, exec <command> = run command (the rest of the line) using shell # b, break = stop here (continue rebase later with 'git rebase --continue') # d, drop <commit> = remove commit
将c37146f前面的pick修改为e,保存并退后后git会输出一下内容
1 2 3 4 5 6 7 8
Stopped at c37146f... d You can amend the commit now, with
git rebase - i HEAD~2 > pick 3437126 c pick e78c223 修改commit b # Rebase c37146f..e78c223 onto c37146f (2 commands) # # Commands: # p, pick <commit> = use commit ...
因为需要将e78c223合并到他的上次提交,需要把e78c223前面的pick改为s
1 2 3 4 5 6 7 8 9 10
git rebase - i HEAD~2 > pick 3437126 c s e78c223 修改commit b # Rebase c37146f..e78c223 onto c37146f (2 commands) # # Commands: # p, pick <commit> = use commit ...
保存并退出,git会弹出新的文本框
1 2 3 4 5 6 7 8 9 10 11
# This is a combination of 2 commits. # This is the 1st commit message:
c # This is the commit message #2:
修改commit b # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit.
修改commit信息
1 2 3 4 5 6 7 8 9 10 11
# This is a combination of 2 commits. # This is the 1st commit message:
新的commit c # This is the commit message #2:
新的commit 修改commit b # Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit.
git show 88a2a47 > commit 88a2a47912f3fe643d486739b000dfae776ed493 (HEAD -> master) Author: you <youemail@outlook.com> Date: Fri Sep 9 10:26:37 2022 +0800
新的commit c
新的commit 修改commit b
diff --git a/b.txt b/b.txt new file mode 100644 index 0000000..63d8dbd --- /dev/null +++ b/b.txt @@ -0,0 +1 @@ +b \ No newline at end of file diff --git a/c.txt b/c.txt new file mode 100644 index 0000000..d36cf97 --- /dev/null +++ b/c.txt @@ -0,0 +1 @@ +ccccc \ No newline at end of file