我们通常通过 Github 进行协作工作,有时候在提交 PR 过程中,可能存在与别人已合并 PR 的冲突问题,此时便可以通过 rebase 操作解决这些问题并重新提交 PR,下面我们将这个过程简单描述记录一下。
首先让我们在脑子中构造一个简单的场景:当我们提交一个 PR 到 Github 的主仓库时,此时通过 Github 的检查发现存在很多与主分支的冲突,这些冲突并不能通过在 PR 中进行对应文件的修改解决。
此时我们需要做如下操作:

# chris @ ChrisdeMacBook-Pro in ~/dolphinscheduler/dolphinscheduler on git:PR-fix-wordcase-issue x [8:48:45] C:128
$ git rebase dev
$ git rebase dev
Auto-merging dolphinscheduler-ui/src/views/projects/task/components/node/types.ts
Auto-merging dolphinscheduler-ui/src/views/projects/task/components/node/format-data.ts
Auto-merging dolphinscheduler-ui/src/views/projects/task/components/node/fields/index.ts
Auto-merging dolphinscheduler-ui/src/locales/en_US/project.ts
Auto-merging dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTask.java
Auto-merging dolphinscheduler-task-plugin/dolphinscheduler-task-procedure/src/main/java/org/apache/dolphinscheduler/plugin/task/procedure/ProcedureTask.java
Auto-merging dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/test/java/org/apache/dolphinscheduler/plugin/task/dq/DataQualityTaskTest.java
CONFLICT (content): Merge conflict in dolphinscheduler-task-plugin/dolphinscheduler-task-dataquality/src/test/java/org/apache/dolphinscheduler/plugin/task/dq/DataQualityTaskTest.java
Auto-merging dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/parameters/SqlParametersTest.java
Auto-merging dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/parameters/SqlParameters.java
Auto-merging dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
Auto-merging dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/DataSourceMapperTest.java
Auto-merging dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/DatasourceUser.java
CONFLICT (content): Merge conflict in dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/DatasourceUser.java
Auto-merging dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/DqRuleServiceTest.java
Auto-merging dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java
Auto-merging dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
Auto-merging dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DqRuleServiceImpl.java
Auto-merging dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/python/PythonGateway.java
Auto-merging docs/configs/docsdev.js
error: could not apply 1df0c5016... modify Datasource to DataSource on all related files
Resolve all conflicts manually, mark them as resolved with
"git add/rm ", then run "git rebase --continue".
You can instead skip this commit: run "git rebase --skip".
To abort and get back to the state before "git rebase", run "git rebase --abort".
Could not apply 1df0c5016... modify Datasource to DataSource on all related files rebase and repush
git add xxx,然后继续执行 git rebase --continuegit rebase --abort 来终止 rebase整个 rebase 的过程记录大体如上,基本可以解决所有 PR 提交过程中产生冲突的情况,希望能帮助大家。