零、这是一个好东西
一、Rebase和Merge【二选一】
- 比如你有 master 分支 ,然后还有dev分支 ,master 用户线上发布 dev 用于开发,release 用于上线前测试验证 ,hotfix 用于线上问题解决,bugfix用于bug解决,feature用于你的开发。
1、merge
这个大家铁定都知道,因为用的实在是太多了,它大概的意思,我先举个栗子。
在开发的过程中,团队中的所有研发在领到需求侯,都会基于dev拉取自己的分支比如feature/xy1、feature/xy2 ,在使用merge的情况下它的操作是这样的:
2、rebase
已经知道了merge后整个图是非常的不beautiful,所以rebase这个变基操作就出现了。
reabse就是重新给你整理一下提交记录,让其合过去之后非常的beautiful。见图:
二、一次实操记录
# 当前分支是feature/当前分支[你自己的分支]V1 我们将 feature/xy01rebase到当前分支上 D:\workspace\xywork\rebase-demo>git rebase feature/xy01 First, rewinding head to replay your work on top of it... Applying: feature/当前分支[你自己的分支]V1 .git/rebase-apply/patch:78: trailing whitespace. .git/rebase-apply/patch:82: trailing whitespace. 要检出项目并从源代码构建, 请执行以下操作: .git/rebase-apply/patch:1006: trailing whitespace. .git/rebase-apply/patch:1087: trailing whitespace. .git/rebase-apply/patch:1690: trailing whitespace. warning: squelched 57 whitespace errors warning: 62 lines add whitespace errors. Using index info to reconstruct a base tree... Falling back to patching base and 3-way merge... CONFLICT (add/add): Merge conflict in pom.xml Auto-merging pom.xml CONFLICT (add/add): Merge conflict in rebase-demo-server/src/main/resources/application.yml Auto-merging rebase-demo-server/src/main/resources/application.yml CONFLICT (add/add): Merge conflict in rebase-demo-server/src/main/resources/application-dev.yml Auto-merging rebase-demo-server/src/main/resources/application-dev.yml CONFLICT (add/add): Merge conflict in rebase-demo-server/src/main/java/com/yangzai/xywork/server/tree/DossierTreeLogic.java Auto-merging rebase-demo-server/src/main/java/com/yangzai/xywork/server/tree/DossierTreeLogic.java CONFLICT (add/add): Merge conflict in rebase-demo-server/src/main/java/com/yangzai/xywork/server/timer/TimerTask.java Auto-merging rebase-demo-server/src/main/java/com/yangzai/xywork/server/timer/TimerTask.java CONFLICT (add/add): Merge conflict in rebase-demo-server/src/main/java/com/yangzai/xywork/server/service/cache/MobileCacheService.java Auto-merging rebase-demo-server/src/main/java/com/yangzai/xywork/server/service/cache/MobileCacheService.java CONFLICT (add/add): Merge conflict