git (6) -- git rebase 优化已提交的commit
git (6) -- git rebase 优化已提交的commit

git rebase -i HEAD~2

git (6) -- git rebase 优化已提交的commit
git (6) -- git rebase 优化已提交的commit

git (6) -- git rebase 优化已提交的commit

[email protected] git_command_test [fix] $ git rebase  -i HEAD~2
[detached HEAD c35c855] delete a line
 Date: Fri Jan 18 22:03:20 2019 +0800
 1 file changed, 1 deletion(-)
[detached HEAD b1bb676] delete a line
 Date: Fri Jan 18 22:03:20 2019 +0800
 1 file changed, 1 insertion(+), 2 deletions(-)
Successfully rebased and updated refs/heads/fix.
[email protected] git_command_test [fix] $ git status
On branch fix
nothing to commit, working tree clean
[email protected] git_command_test [fix] $ git log -2
commit b1bb676a84c5b4cbc3b64659ebd1117848056dd3 (HEAD -> fix)
Author: doctording <[email protected]>
Date:   Fri Jan 18 22:03:20 2019 +0800

    delete a line

    change a line

commit c8343644cbcffdffa08766fb5b28bef35a231bf2 (origin/master, origin/HEAD, master)
Author: doctording <[email protected]>
Date:   Sat Aug 19 21:49:16 2017 +0800

    modify bbb to BBB
[email protected] git_command_test [fix] $
git push --set-upstream origin fix

变成了一个commit (如果要修改commit的message也可以采用此方法)
git (6) -- git rebase 优化已提交的commit

相关文章: