$ git log commit 4689f4d16251bd9c692f182ddcf8fa744e7c3040 (HEAD -> master) Author: lmy <lmy@lmy.lmy> Date: Sat Feb 22 16:35:04 2020 +0800
Modify style.scss content
commit 575eb324d6933565c26c75d8e198c9348b3f482f Author: lmy <lmy@lmy.lmy> Date: Sat Feb 22 13:27:21 2020 +0800
Rename style.css to style.scss
commit f4d1584be08bf36f31b3c4442604a233ba811eb9 Author: lmy <lmy@lmy.lmy> Date: Sat Feb 22 13:13:33 2020 +0800
Add style.css
commit 8df90bcccc65ee27aee90166ca65887d6415bc3b Author: ScarboroughCoral <3249977074@qq.com> Date: Sat Feb 22 13:09:25 2020 +0800
Add index+logo ################################################################## $ git rebase -i 8df90 #################################### 将除了最早的commit合并 [detached HEAD ae9bbaf] create a complete web page Date: Sat Feb 22 13:13:33 2020 +0800 1 file changed, 7 insertions(+) create mode 100644 style.scss Successfully rebased and updated refs/heads/master. ########################################################################### $ git log commit ae9bbaf72e24972246579de21136c72328a3c94b (HEAD -> master) Author: lmy <lmy@lmy.lmy> Date: Sat Feb 22 13:13:33 2020 +0800
create a complete web page
Add style.css
Rename style.css to style.scss
Modify style.scss content
commit 8df90bcccc65ee27aee90166ca65887d6415bc3b Author: ScarboroughCoral <3249977074@qq.com> Date: Sat Feb 22 13:09:25 2020 +0800
Add index+logo
0x05 合并多个间隔的commit
和合并连续的commit类似。还是对commit的父commit进行reabse。在rebase交互界面中将需要合并的间隔的commit放在一起(连续),将后续的commit进行squash即可。 不过在第二步添加commit message时出现问题跳出交互界面,按照提示进行git rebase --continue进行操作即可。
$ git rebase -i 8df90bcc interactive rebase in progress; onto 8df90bc Last commanddone (1 commanddone): pick 8df90bc Next commands to do (2 remaining commands): squash 6e5d8a8 Add test pick f4d1584 Add style.css You are currently rebasing branch 'temp' on '8df90bc'.
nothing to commit, working tree clean The previous cherry-pick is now empty, possibly due to conflict resolution. If you wish to commit it anyway, use:
git commit --allow-empty
Otherwise, please use 'git reset' Could not apply 8df90bc...
#################################################################### $ git status interactive rebase in progress; onto 8df90bc Last commanddone (1 commanddone): pick 8df90bc Next commands to do (2 remaining commands): squash 6e5d8a8 Add test pick f4d1584 Add style.css (use "git rebase --edit-todo" to view and edit) You are currently rebasing branch 'temp' on '8df90bc'. (all conflicts fixed: run "git rebase --continue") ############################ 出现问题,使用 rebase --continue命令继续交互 ####################################################################### $ git rebase --continue [detached HEAD 5c248b3] add index & test Author: ScarboroughCoral <3249977074@qq.com> Date: Sat Feb 22 13:09:25 2020 +0800 2 files changed, 19 insertions(+) create mode 100644 index.html create mode 100644 readme.md Successfully rebased and updated refs/heads/temp.