语雀内容
    如果修改的是已推送到远程的提交(commit),则可能会对其他协作者造成冲突。

    要将选中的 commit 拆分为两个 commit。使针对内容的修改更加语义化
    image.png

    1. # 执行后 git rebase 后,会停留到 vim 界面上,找到需要拆分的提交,将 pick 修改为 edit
    2. ## e, edit <commit> = use commit, but stop for amending
    3. $ git rebase -i b80da87^
    4. Stopped at b80da87... feat: 系统管理任务调度页面
    5. You can amend the commit now, with
    6. git commit --amend
    7. Once you are satisfied with your changes, run
    8. git rebase --continue
    1. $ git status
    2. interactive rebase in progress; onto 7036f31
    3. Last command done (1 command done):
    4. edit b80da87 feat: 系统管理任务调度页面
    5. Next commands to do (53 remaining commands):
    6. pick ca2bffa feat: 系统管理-任务调度-任务执行列表功能修改
    7. pick 935b774 feat: 任务执行列表-编辑任务 从能投项目复制相关页面资源
    8. (use "git rebase --edit-todo" to view and edit)
    9. You are currently editing a commit while rebasing branch 'warIndustry' on '7036f31'.
    10. (use "git commit --amend" to amend the current commit)
    11. (use "git rebase --continue" once you are satisfied with your changes)
    12. nothing to commit, working tree clean
    1. # 将暂存区与 HEAD 的文件重置为上一次状态,选择需要提交的内容去提交(分离提交);
    2. ## 类似文件修改但未执行 git add 前的状态
    3. ## 如果只需要修改 commit Msg,执行 git commit --amend 就可以了
    4. $ git reset HEAD^
    5. Unstaged changes after reset:
    6. M server.js
    7. M template/sysManage/taskDispatch.html
    8. ## 按照正常编写代码提交流程,修改代码处理。(下面是伪代码,实际上,我将一个提交拆分为了三个提交)
    9. $ git add server.js
    10. $ git commit -m "AAA"
    11. $ git status
    12. interactive rebase in progress; onto 7036f31
    13. Last command done (1 command done):
    14. edit b80da87 feat: 系统管理任务调度页面
    15. Next commands to do (53 remaining commands):
    16. pick ca2bffa feat: 系统管理-任务调度-任务执行列表功能修改
    17. pick 935b774 feat: 任务执行列表-编辑任务 从能投项目复制相关页面资源
    18. (use "git rebase --edit-todo" to view and edit)
    19. You are currently editing a commit while rebasing branch 'warIndustry' on '7036f31'.
    20. (use "git commit --amend" to amend the current commit)
    21. (use "git rebase --continue" once you are satisfied with your changes)
    22. Changes to be committed:
    23. (use "git reset HEAD <file>..." to unstage)
    24. modified: template/sysManage/taskDispatch.html
    25. $ git add template/sysManage/taskDispatch.html
    26. $ git commit -m "BBB"
    27. $ git status
    28. interactive rebase in progress; onto 7036f31
    29. Last command done (1 command done):
    30. edit b80da87 feat: 系统管理任务调度页面
    31. Next commands to do (53 remaining commands):
    32. pick ca2bffa feat: 系统管理-任务调度-任务执行列表功能修改
    33. pick 935b774 feat: 任务执行列表-编辑任务 从能投项目复制相关页面资源
    34. (use "git rebase --edit-todo" to view and edit)
    35. You are currently editing a commit while rebasing branch 'warIndustry' on '7036f31'.
    36. (use "git commit --amend" to amend the current commit)
    37. (use "git rebase --continue" once you are satisfied with your changes)
    38. # 拆分完成
    39. $ git rebase --continue
    40. Successfully rebased and updated refs/heads/warIndustry.