git add ./
git commit -m"oooooooo"
git rebase -i HEAD~2 (索引从1开始,同理若更改前n次的commit,此处改为n即可)
显示如下:
pick 238fedf balabala。
pick 941fb81 oooooooo
# Rebase 3c79056..941fb81 onto 3c79056
#
# 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
#
# If you remove a line here THAT COMMIT WILL BE LOST.
# However, if you remove everything, the rebase will be aborted.
修改 pick 941fb81 oooooooo
为: s 941fb81 oooooooo
ctrl+x
Y
enter
显示如下:
# This is a combination of 2 commits.
# The first commit's message is:
balabalabala
Change-Id: I484981f3db67e10090802331ee0067353a710c7e
# This is the 2nd commit message:
oooooooo
Change-Id: If2ce5e712d5bfa6352bab9b2067f4adf3c913811
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# Not currently on any branch.
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: AndroidManifest.xml
将第二个提交信息注释掉:
#oooooooo
#Change-Id: If2ce5e712d5bfa6352bab9b2067f4adf3c913811
Ctrl+x
git push HEAD:balabala 即可。
法2:
提交了第一个记录,未审核,需修改。
1. 修改。
2. git add ./
3. git commit --amend
4. git push origin HEAD:refs/changes/460546
460546 为上次提交的change。
本文介绍了如何使用 `git rebase -i HEAD~2` 合并最近两次提交到上一次未审查的提交中,详细阐述了rebase交互式编辑过程,包括将提交融合(squash)及修改提交信息的步骤。此外,还提供了另一种通过 `git commit --amend` 和 `git push` 修改未审核提交的方法。
278

被折叠的 条评论
为什么被折叠?



