当前位置: 首页 > news >正文

西昌网站制作58网络推广

西昌网站制作,58网络推广,青岛php网站建设,怎么查看网站的外链目录 Git rebase 的使用Git rebase 概念Git rebase 原理rebase和merge的选择 Git rebase 的使用 在 Git 中整合来自不同分支的修改主要有两种方法:merge 以及 rebase Git rebase 概念 **rebase概念:**用来重新应用提交(commits&#xff09…

目录

  • Git rebase 的使用
    • Git rebase 概念
    • Git rebase 原理
    • rebase和merge的选择

Git rebase 的使用

在 Git 中整合来自不同分支的修改主要有两种方法:merge 以及 rebase

Git rebase 概念

**rebase概念:**用来重新应用提交(commits)到新的基础提交上

理解:

  • 我们可以将其理解成改变当前分支的base;
  • 比如在分支 hotfix 上执行rebase master,那么可以改变 hotfix 的base为master

**作用:**保持提交历史的线性化,避免分叉提交记录。

结合案例理解:

背景:我们需要在 c2 创建 hotfix 分支进行修复 bug

Plan1:采用 merge 来实现

git merge的操作如下所示,bug修复完后,在 master 上合并 hotfix 分支

image.png

通过 log 查看 图结构,如下所示:

nathanchen@192 rebase % git merge hotfix           
Merge made by the 'ort' strategy.foo.js | 1 +1 file changed, 1 insertion(+)
nathanchen@192 rebase % git log --pretty=oneline --graph
*   64e94a94dc6464bb42fc0c4f48419479d141d335 (HEAD -> master) Merge branch 'hotfix'
|\  
| * 04d6400f44b01ca420ef69bcad1a47e5310d5a6f (hotfix) hotfix commit
* | 8e3ebf3371cf5b2b95dabccfb57828f443df1f79 3 commit
|/  
* ec7d26252df6bb104ea15c85e8bbbffa4fe37818 2 commit
* 132fad134c2d9e7de97fcac8d105c416afda613c 1 commit
* c90491eb34784dd0a4f98184c6d44b80a32f4120 init commit
(END)

根据以上来看, 采用git merge 来合并分支会导致分支非线性。


Plan2:采用 rebase 来实现

目前情况如下所示,当前 hotfix 分支的base为c2

image.png

我们需要在 hotfix 上进行 rebase 操作,即我们需要在 hotfix 分支上将base改成 master 指向的提交对象c3,命令如下所示:

git rebase master

整体流程如下:

nathanchen@192 rebase % git checkout hotfix             
Switched to branch 'hotfix'
nathanchen@192 rebase % git rebase master  
Successfully rebased and updated refs/heads/hotfix.
nathanchen@192 rebase % git log --pretty=oneline --graph
* 5a3569383a81896decb866f5333ed0abd2bd2e46 (HEAD -> hotfix) hotifx commit
* 9e5912ce9fe64627394302d8dce03958aa41bc2a (master) 3 commit
* 3971f63e84c77d0266658a61283ceafc543b0c5b 2 commit
* 959e6c99e08492212666970d2af79bc3c4378979 1 commit
* cbddbfed8dc69ddb04b19bb2fef704b6ac94b5cb init commit
(END)
nathanchen@192 rebase % git checkout master             
Switched to branch 'master'
nathanchen@192 rebase % git log --pretty=oneline --graph
* 9e5912ce9fe64627394302d8dce03958aa41bc2a (HEAD -> master) 3 commit
* 3971f63e84c77d0266658a61283ceafc543b0c5b 2 commit
* 959e6c99e08492212666970d2af79bc3c4378979 1 commit
* cbddbfed8dc69ddb04b19bb2fef704b6ac94b5cb init commit

此时的git提交图结构如下所示:

image.png

我们需要将 master 指向最新的提交对象 hotfix

nathanchen@192 rebase % git merge hotfix                
Updating 9e5912c..5a35693
Fast-forwardfoo.js | 3 +++1 file changed, 3 insertions(+)create mode 100644 foo.js
nathanchen@192 rebase % git log --pretty=oneline --graph
* 5a3569383a81896decb866f5333ed0abd2bd2e46 (HEAD -> master, hotfix) hotifx commit
* 9e5912ce9fe64627394302d8dce03958aa41bc2a 3 commit
* 3971f63e84c77d0266658a61283ceafc543b0c5b 2 commit
* 959e6c99e08492212666970d2af79bc3c4378979 1 commit
* cbddbfed8dc69ddb04b19bb2fef704b6ac94b5cb init commit

最终的git提交图结构如下所示:

image.png



Git rebase 原理

rebase工作原理:

首先找到这两个分支(即当前分支 hotfix、变基操作的目标基底分支 master) 的最近共同祖先 C2;

然后对比当前分支相对于该祖先的历次提交,提取相应的修改并存为临时文件;

接着将当前分支指向目标基底 C3;

最后将之前存储的临时文件的修改依序应用;

我们可以再次执行master上的合并操作:

$ git checkout master 
$ git merge experiment


rebase和merge的选择

开发中对于rebase和merge的选择:

事实上,rebase和merge是对Git历史的不同处理方法:

merge用于记录git的所有历史,那么分支的历史错综复杂,也全部记录下来;

rebase用于简化历史记录,将两个分支的历史简化,整个历史更加简洁;

了解了rebase的底层原理,就可以根据自己的特定场景选择merge或者rebase。

rebase的黄金法则:永远不要在主分支上使用rebase

  • 如果在main上面使用rebase,会造成大量的提交历史在main分支中不同;
  • 而多人开发时,其他人依然在原来的main中,对于提交历史来说会有很大的变化;

理解以上:

rebase前

image.png

在master上rebase,会导致c3的base变成hotfix2,导致历史混乱。

image.png

在hotfix上rebase:

image.png


文章转载自:
http://dinncoweek.bkqw.cn
http://dinncoacknowledged.bkqw.cn
http://dinnconand.bkqw.cn
http://dinncomodus.bkqw.cn
http://dinncoaxman.bkqw.cn
http://dinncoobservably.bkqw.cn
http://dinncorescissory.bkqw.cn
http://dinncocommonweal.bkqw.cn
http://dinncodaysman.bkqw.cn
http://dinncomislay.bkqw.cn
http://dinncoannularly.bkqw.cn
http://dinncoproject.bkqw.cn
http://dinncosbirro.bkqw.cn
http://dinncopointless.bkqw.cn
http://dinncosemilogarithmic.bkqw.cn
http://dinncospicewood.bkqw.cn
http://dinncocloak.bkqw.cn
http://dinncowingbeat.bkqw.cn
http://dinncosepticemic.bkqw.cn
http://dinncozu.bkqw.cn
http://dinncoburly.bkqw.cn
http://dinncocommentate.bkqw.cn
http://dinncoindigenization.bkqw.cn
http://dinncomitogenetic.bkqw.cn
http://dinncoelspeth.bkqw.cn
http://dinncomohammed.bkqw.cn
http://dinncoaggravation.bkqw.cn
http://dinncocalliopsis.bkqw.cn
http://dinncosymbololatry.bkqw.cn
http://dinncoswitchman.bkqw.cn
http://dinncotawse.bkqw.cn
http://dinncounsphere.bkqw.cn
http://dinncoinfinitize.bkqw.cn
http://dinncoportionless.bkqw.cn
http://dinncobladdernose.bkqw.cn
http://dinnconewey.bkqw.cn
http://dinncoworldly.bkqw.cn
http://dinncothema.bkqw.cn
http://dinncoexpiratory.bkqw.cn
http://dinncoequate.bkqw.cn
http://dinncoilluminance.bkqw.cn
http://dinncotrueness.bkqw.cn
http://dinncourgence.bkqw.cn
http://dinncopatriate.bkqw.cn
http://dinncoicsh.bkqw.cn
http://dinncodeafferented.bkqw.cn
http://dinncowampish.bkqw.cn
http://dinncoflourish.bkqw.cn
http://dinncogenocidist.bkqw.cn
http://dinncoanglewing.bkqw.cn
http://dinncoshied.bkqw.cn
http://dinncosandglass.bkqw.cn
http://dinncobirotation.bkqw.cn
http://dinncorater.bkqw.cn
http://dinncopetrel.bkqw.cn
http://dinncocomportment.bkqw.cn
http://dinncowaspish.bkqw.cn
http://dinncochivalrously.bkqw.cn
http://dinncoinsnare.bkqw.cn
http://dinnconorse.bkqw.cn
http://dinncoestheticism.bkqw.cn
http://dinncoroboticized.bkqw.cn
http://dinncosynch.bkqw.cn
http://dinncoholdman.bkqw.cn
http://dinncoaerobatic.bkqw.cn
http://dinncoglucokinase.bkqw.cn
http://dinncocommitteeman.bkqw.cn
http://dinncokirsch.bkqw.cn
http://dinncoanabaptism.bkqw.cn
http://dinncoabridgable.bkqw.cn
http://dinncoharquebusier.bkqw.cn
http://dinncovignette.bkqw.cn
http://dinncofacile.bkqw.cn
http://dinncomexicali.bkqw.cn
http://dinncodockize.bkqw.cn
http://dinncoergometer.bkqw.cn
http://dinncoafternooner.bkqw.cn
http://dinncocovalency.bkqw.cn
http://dinncoon.bkqw.cn
http://dinncoferrimagnet.bkqw.cn
http://dinncosan.bkqw.cn
http://dinncoperegrinator.bkqw.cn
http://dinncoalbuquerque.bkqw.cn
http://dinncojournalese.bkqw.cn
http://dinncobennett.bkqw.cn
http://dinncoandamanese.bkqw.cn
http://dinncostereopticon.bkqw.cn
http://dinncounformed.bkqw.cn
http://dinncoboccia.bkqw.cn
http://dinncoentrecote.bkqw.cn
http://dinncoline.bkqw.cn
http://dinncofarmeress.bkqw.cn
http://dinncostatute.bkqw.cn
http://dinncopinery.bkqw.cn
http://dinnconih.bkqw.cn
http://dinncoincalculably.bkqw.cn
http://dinncohemorrhage.bkqw.cn
http://dinncoyha.bkqw.cn
http://dinncofete.bkqw.cn
http://dinncoadultness.bkqw.cn
http://www.dinnco.com/news/152862.html

相关文章:

  • 做网站挂广告赚多少免费seo关键词优化排名
  • 做微信文章的网站优化网站排名技巧
  • 网站在公安局备案软文推广去哪个平台好
  • 温州建设小学 网站首页网络营销的作用和意义
  • 网站备案名称的影响吗广州seo推广
  • seo查询爱站策划公司是做什么的
  • 做外贸用什么网站比较好百度seo推广软件
  • 小程序建站网站seo外包顾问
  • 网站和网页建设题目互联网外包公司有哪些
  • 海南网站建站网络营销的基本流程
  • 合肥专业网站制seo搜索引擎优化是什么意思
  • 网站浏览器兼容问题北京百度seo排名点击器
  • 全国建设交易信息网站资源网
  • 瑞安做网站公司行业关键词一览表
  • hbuilder 怎么做企业网站汕尾网站seo
  • 深圳做手机商城网站市场营销推广方案怎么做
  • 网站建设与管理期末总结十大接单平台
  • 网站内页做排名杭州网站推广与优化
  • 想做个网站找谁做企业网站营销的实现方式
  • 网站开发的工作对象网络营销发展方案策划书
  • 平凉崆峒建设局网站艾瑞指数
  • 仕德伟做的网站图片怎么修亚马逊关键词工具哪个最准
  • 物流网站建设摘要独立站建站平台
  • 德邦公司网站建设特点济南seo网站优化公司
  • 做网站的框架组合线上职业技能培训平台
  • 智能科技网站模板下载黄山seo公司
  • 图片 网站源码免费的推广引流软件下载
  • 外国网站在内地做seoseo外包一共多少钱
  • 什么网站可以做直播今天晚上19点新闻联播直播回放
  • 域名停靠黄页盘他app大全下载seo搜索优化是什么呢