Git 更改 commit 的操作
git rebase -i HEAD~<number 代表需要处理几个 commit>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25Rebase ddebba2..a54dc28 onto 9d9ba60 (15 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
l, label <label> = label current HEAD with a name
t, reset <label> = reset HEAD to a label
m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]
. create a merge commit using the original merge commit's
. message (or the oneline, if no original merge commit was
. specified). Use -c <commit> to reword the commit message.
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
6pick 54f205a Update README.md
pick e1deb05 Update README.md
pick 3a33ad2 Update README.md
pick 225a513 Update README.md
pick d44d34b Update README.md
pick 657d8c2 Update README.md1
2
3
4
5
6pick 54f205a Update README.md
pick e1deb05 Update README.md
squash 3a33ad2 Update README.md
squash 225a513 Update README.md
squash d44d34b Update README.md
squash 657d8c2 Update README.md这样就可以把最上面两个 Message 保留,把后面的 Message 去掉
最后
git push --force