语雀内容
如果修改的是已推送到远程的提交(commit),则可能会对其他协作者造成冲突。
要将选中的 commit 拆分为两个 commit。使针对内容的修改更加语义化
# 执行后 git rebase 后,会停留到 vim 界面上,找到需要拆分的提交,将 pick 修改为 edit## e, edit <commit> = use commit, but stop for amending$ git rebase -i b80da87^Stopped at b80da87... feat: 系统管理任务调度页面You can amend the commit now, withgit commit --amendOnce you are satisfied with your changes, rungit rebase --continue
$ git statusinteractive rebase in progress; onto 7036f31Last command done (1 command done):edit b80da87 feat: 系统管理任务调度页面Next commands to do (53 remaining commands):pick ca2bffa feat: 系统管理-任务调度-任务执行列表功能修改pick 935b774 feat: 任务执行列表-编辑任务 从能投项目复制相关页面资源(use "git rebase --edit-todo" to view and edit)You are currently editing a commit while rebasing branch 'warIndustry' on '7036f31'.(use "git commit --amend" to amend the current commit)(use "git rebase --continue" once you are satisfied with your changes)nothing to commit, working tree clean
# 将暂存区与 HEAD 的文件重置为上一次状态,选择需要提交的内容去提交(分离提交);## 类似文件修改但未执行 git add 前的状态## 如果只需要修改 commit Msg,执行 git commit --amend 就可以了$ git reset HEAD^Unstaged changes after reset:M server.jsM template/sysManage/taskDispatch.html## 按照正常编写代码提交流程,修改代码处理。(下面是伪代码,实际上,我将一个提交拆分为了三个提交)$ git add server.js$ git commit -m "AAA"$ git statusinteractive rebase in progress; onto 7036f31Last command done (1 command done):edit b80da87 feat: 系统管理任务调度页面Next commands to do (53 remaining commands):pick ca2bffa feat: 系统管理-任务调度-任务执行列表功能修改pick 935b774 feat: 任务执行列表-编辑任务 从能投项目复制相关页面资源(use "git rebase --edit-todo" to view and edit)You are currently editing a commit while rebasing branch 'warIndustry' on '7036f31'.(use "git commit --amend" to amend the current commit)(use "git rebase --continue" once you are satisfied with your changes)Changes to be committed:(use "git reset HEAD <file>..." to unstage)modified: template/sysManage/taskDispatch.html$ git add template/sysManage/taskDispatch.html$ git commit -m "BBB"$ git statusinteractive rebase in progress; onto 7036f31Last command done (1 command done):edit b80da87 feat: 系统管理任务调度页面Next commands to do (53 remaining commands):pick ca2bffa feat: 系统管理-任务调度-任务执行列表功能修改pick 935b774 feat: 任务执行列表-编辑任务 从能投项目复制相关页面资源(use "git rebase --edit-todo" to view and edit)You are currently editing a commit while rebasing branch 'warIndustry' on '7036f31'.(use "git commit --amend" to amend the current commit)(use "git rebase --continue" once you are satisfied with your changes)# 拆分完成$ git rebase --continueSuccessfully rebased and updated refs/heads/warIndustry.
