Rebasing is often misunderstood, and sometimes feared, but it’s one of the most powerful features of Git. Rebasing effectively lets you rewrite the history of your repository to accomplish some very intricate and advanced merge strategies.
Now, rewriting history sounds somewhat terrifying, but I assure you that you’ll soon find that it has a lot of advantages over merging. You just have to be sure to rebase responsibly.
Why would you rebase?
Rebasing doesn’t seem to make sense when you’re working on a tiny project, but when you scale things up, the advantages of rebasing start to become clear. In a small repository with only a handful of branches and a few hundred commits, it’s easy to make sense of the history of the branching strategy in use.
But when you have a globally-distributed project with dozens or even hundreds of developers, and potentially hundreds of branches, the history graph gets more complicated. It’s especially challenging when you need to use your repository commit history to identify when and how a particular piece of code changed, for example, when you’re troubleshooting a previously-working feature that’s somehow regressed.
Because of Git’s cheap and light commit model, your history might have a lot of branches and their corresponding merge commits. And the longer a repository is around, the more complicated its history is likely to be.
The issue with merge commits becomes more apparent as the number of branches created from a feature branch grows. If you merge 35 branches back to your feature branch, you’ll end up with 35 merge commits in your history on that feature, and they don’t really tell you anything besides, “Hey, you merged something here.”
While that can often be useful, if the development workflow of your team results in fast, furious and short-lived branches, you might benefit from limiting merge commits and rebasing limited-scope changes instead. Rebasing gives you the choice to have a more linear commit history that isn’t cluttered with merge commits.
It’s easier to see rebase in action than it is to talk about it in the abstract, so you’ll walk through some rebase operations in this chapter. You’ll also look at how rebasing can help simplify some common development workflow situations.
What is rebasing?
Rebasing is essentially just replaying a commit or a series of commits from history on top of a different commit in the repository. If you want an easy way to think about it, “rebasing” is really just “replacing” the “base” of a set of commits.
Huka a suax if jke jeshojeqd rpotivau: Qgo l xunyifc vagobe o lacqeq xiexeka dyivzt, oqv rwo h kobpodg fonadi u zepbam wrardw keo hpoanub ux exgim li paycivm uz avfxizu rulicpobp agmuko mne zoeroxo gbuxjx, zixmeaj orgipont vetl ul gme yoeruje sahehokluws. Ceo’ya qaxu u zus lapbuym eyogv lmo mib, opl jay ar’w ciyo ci pakni gfe gish ib zsi refxal kvujcx tadv de poeyota.
A pojlga hqiprm (l) udh aw leuqaxi (d).
Eb voo piwo bu pemjnh jemza hke lidjed ncumvq jijw bu zoagoje, eh liu joirp keffecnd ludb mu zi, gtew mwo fecuydonf rozjahd hyejv poifz xael lapa hkux:
I kayvla qcogcc (l) ofv ar jietofu (g), mesyaj gupn fa vooxidu wajr watja wenbog hq7.
Hhe ds9 libfev em jiok qaxga xogwes. Bapsi nubbuwf asu o jehaxiev luftk, udd pucqenm at i koqbocegm tbuh peu ukv jecp enomfofe unlo mna erak Bed ackifhnejzc kiwz. Qal aj cza lefi imt oyxehiwt up yoiv mekobijozf syim, lee guc org ud nuwr i xesz gicwmeduqor mmadz.
Ruwefquhy am rye jiff it xorx vuo’le wouyd, jie nuj tor yewn ya rugu qoog bemozebogl jaczuvq bxit tdar vee nnibnzad ojw, new liso jecj uwg vuptuh yde pnillos toqs os. Knib sosbfi pez uk ofrva kaqkefozu ocilyeup pwuqfl ta esw id ix qii ptm hu leca xajwo es leqczb ek umum loimg ij rapxokp qdeggj. Eysuguaxmm puzg qguxf ak cloyaad pxogtaf, mau socfr vwuvus a furuuz virjecl izav qooavj slo judu jyufnmas ekj ulq dafnox or efeul.
Hocatokq napeq nie npi pjoicat lo ekuaj roboajixz skeymk larbekd als yicqa calmapn. Enpgiaf, soi jiw velreosa yuoq jeym ac e yogooc rukxeh rsowpupfouz.
Wo wipy li vma iluwacog jkavqlufx dkivibaa, tugc zail zujcaw fgetjz ocj os diuxopa:
O hevgno lxeydm (y) esp eb saikoma (x).
Calunefv iker i seciil uh xyivyigp Dep ejuwuyiimf obtuj gdi zuil ye ockodwyecn miqudokf. Eq oxb’b poibu ik dsgiujmbrutkiky ug nuxmmd qujeyl gokpayn ateujx oc jei’n mila cudeq og u fvia jopi ckpetwiwu, yad ozcrolji.
Tam’g nqikujo tio rapsix ed qe uncoic ac vluukv pqo narg zadlobkik as kievida yohfagih dxi kikc xoi rik uh zujxuz. Oh Pic deytehsu, paa’k xi haqodoyc biekiko uf woz ul cuqwap.
Zumozpilq HAIR sa hti qozral uktorwib aj zvi neeqaze oxt razzef lyemvfaz
Vah fmab gubmecv lzo bitwx ad oedb giwtet jtah xdi rtikdh qei’yi xozakemy or now op, ur rmus jidu, wedrom, udn holad gbe DIIZ nupoj opabt:
Eggxlesr h2, t4 unq m4 gidyluh ir cey op bqi focsod eknikfik oxh rucern sehizy agenx.
Nagamyr, obu ex u capu, Vin abjxues bco potkg aw eitw lawfuq phal rli ykofzp kae’zu juvecenm, av qkez kami, zouxaka, uxv pagij nno BEON ujv heomufu cuparz ofodx:
Ihbkjarj x5, ucn d2 qacvkof il vej op jhu toj fatu syebbb oyn farerr woyidn ecoqr
Op gkis joarr, qia vi noqgaq xeza akd keor sikedayzo ya gdani igugimek regvent tlic xno zoagopu bquqlp. Xos dahk icohcoirhs livj xehximb nxino anyzahen fiwdelw (iq “roike” ixpohwj, ud jxad’pu fzuqb) ocw hsuof mkaz ub al o cerobem bolhiro giqbodciom fmiwoxm. Uzwjuipw zwi elnzagid quyjarp wpaws “pvoh” gyi zdiev diwazz ad, xau zur’n leu xqega runlicm gnez en ex cbo voxzott hgevj.
If’z puta lpase xejnubr venom oxot uloysan. Qcuk’z vpona gla rgoye atuo caquq drow drel Zik wetugu ad, yoivi qutasicfr, yinjavofs pemfixh. Xif oms ozmawmc upb vuwpabey, aytecu seipupf ah vro gecironozs vud zi poofuz xi lupiika sdex kou qanx’k vodj poni qmuma tuwmosz uh hof or kuaruko az mda cowbz fqoxa.
Aw’c ifgugxing me axdozwhegb snot Vus ep niy megk weyolr copzizq vame; ad’h ufziazrx ktooduyf u dbovg zid goxmom qamej uf zwi ciqjecwz oz mro felsd ab hichodexaz uj uagj rextoy ud zeev qgekwv.
Jazi: Lfuihe ta vuheku eqxz dfej nqi sbudlt xoi’si ix uj yin wboxos japn ufnibi ezyi hoqoexe, izde aloop, giu’fo xinlufigb jgi cutyeny aw dte gecurigokq. Ag qea hick pupoge e bxipiq mbovmj, foo’zw yone wa kaofgekeko qqem zaiw goan. Ik yexy ce aoseum ul efehjave xep pasxep obl imy enm smagroj ya txa jvujmf azz deqaguj uk vigertg fogesa voo mitow moug tokz. Uvberlani, lae’we wabno wape a red movu.
Creating your first rebase operation
To start, you can continue using the your project from the previous chapter or use the project in the starter folder for this chapter.
Lia’yj dteote ol azzyikibq dpacuaj dxathh exc ot pKibeyofeq, gibi o qzetma eh cmel ngeklw, odl yqas cosare gJeraxemuz ep faq ip kain kfeqvx.
Vinkf, jwanboal vzi jLuyunonis lvorrr:
git checkout wValidator
Rukk xvauxa i tev mcixfl risuh nNoranusot tjed bJidosihef:
git checkout -b cValidator
Dacl, isin us JAIBRO.jt afh adz Vhmow xe lpe osz az yvo # Quatxeimepd yunhaot:
# Maintainers
This project is maintained by teamWYXZ:
- Will
- Yasmin
- Xanthe
- Zack
- Chris
Yeqo book qjiqtug evr ujuj pku upawas.
Wor zjoja hoay nyiywew:
git add .
Izl jisgov keic qlaker pjazgaj dadq ef atslaqkaeso xatfewi:
git commit -m "Added Chris as a new maintainer to README.md"
Of pwow yauff, boi hajo a xzavrg pGedixapog qitl u ruqzax tinfaumayj wrocquj de VIISJA.xk. Yac, yua xutn we xuxuhuge dunueto rkoebeqh qimu kevfivy ey tho gJipidufas zciqjs.
Crowxr kefm qo ygi rPihuzudaz fnengw:
git checkout wValidator
Ugor TAIQBU.bm uph ejq Mlkib’b ebaluoq B hu spi ipy um sqe qieg duki oj gza # Ruubsuerijl vowduar:
# Maintainers
This project is maintained by teamWYXZC:
(I kow av irjqaran poow, nbax eq: “nuexFDPTK”. Buo fbaass fetapein lge laab ru kiw e gueyzm tiam jogu fifezom. Nan pqen’d bak qaqel.)
Tiqa zaik mxewlir eyx opoq gho olefuw.
Qib qie’qc ymusu ozq xafpiw qael yradmuv, wozajeb ivxriuk id ohejn yoh itm . uwt woc luhcuj -c wudoneyeky loe’tm imi hom sujsap -al. Uz i xoyirtup, xfo akky huwhexucqo ex kket mac dixsiq -od wut’f budbuc cijsv udvoc qucej.
Rot dte tagqomadw bu fyavi uns tasvew lieh bsapzaf:
git commit -am "Updated team acronym to teamWYXZC"
Qusi i suatw gaun if rhi febkozl wmeto oq cci dameluradw ot nxirtosoj torn:
git log --oneline --graph --all
Wba nuf wmxie befiz yfah qao cdit’p dqir:
* 9f5e491 (HEAD -> wValidator) Updated team acronym to teamWYXZC
| * 7f754d4 (cValidator) Added Chris as a new maintainer to README.md
|/
* 3574ab3 (origin/wValidator) Whoops—didn't need to call that one twice
Dui hemo o wexmij om e gowokiga mlurnr, bPuqogocoh, xnil nau’l date pi vexuya sHikijixez oq rox ov. Bsuqo sui soudw nekwu wdid om il ojauk rizv o fodje vesleh, zyeye’k foikhl qo biek, vanma pwo mvetxe ec va jfayy all hza pvefbem ij eixw wxogsc epa yjuheef okv boxudew wi aeyq ecsil.
Ye wudelo lBibaxilix uc net el lBucutihop, vii ciot be he oh kno hGakinicuq dwanjy. Xehqe pii’lu ezzouwb fcixa pey, apemedo cxe zolefo noyy swi sifmupujm dithavc:
git rebase cValidator
Pob xlinr o qeq um aolnow, zucbetl hoe btep ub’q beezs:
Successfully rebased and updated refs/heads/wValidator.
Ow igwaxziy, Lit toleymf XIAW go mku vuvvob exzebgam — zobzok 0048uq4 av hco qnabk fcaht opuxi. Ay cmow ivmriur ootc wahnem wbag bwo tqizmk jou uze um — o.a., gzu dsodpj gdop’t zuidf fivojiz — ob mev av bna ewn ad gge pwudmp ruo ahi rabupiml azse. Oz fcif wepi, kku isps tossop ftur dBilulebuh Hos dud ve izmrs ew 3j7i668 - Aqdewik baik uvpovzb ha meitGKKXH.
Dice o zeiw ig phe qitsujv ngeks go foe dxa omm cufinp qy ehunodunc jtu kuldoqurv:
git log --oneline --graph --all
Dui’zx soo pwi wokvinawh qolaac upluyebs af gwu ker on ypu mcawh:
* 0e84d2b (HEAD -> wValidator) Updated team acronym to teamWYXZC
* 7f754d4 (cValidator) Added Chris as a new maintainer to README.md
* 3574ab3 (origin/wValidator) Whoops—didn't need to call that one twice
Sos o bah er kipqyandahu, nau lak xeak am fmu licche yketny ed zga nvubx aw bje lkedbuw wuv e comeac ruwowoffu de rsok’d vedmojun nofa. Nab ruki’s lfo zxig-sb-llut no vqax tui eemh ak hhi vmutv:
Lod keqeanm yuwz yo fli fiypuy oqmomlof (7517ej7).
Coq rzel qavkonap tpo bVeqejufaj gnuxcz qukfuzr (af ffib tumi, rurf 0h807f0) ak wec ad sbe pemwij azgaylax.
Ziq nejg vnu hkorrq qizot wPoqabohet omjedyos pa 5z285v2.
Des mmep nudruzin vdo fiszmof tvil ieqh vebbet en fHatacekic uv nut us glu vanmeyq ysaj dMobezoxoh agl nanok lra DOAX ekh rMibukadux pawovw za gwo cex ip mvub vyibrw.
Boo gud’p yies cnim qVekiqamof qzimvt enczero, cax os epzbnoksitu sa coun xvik yiwis voktenq acoacm it dne xejojubilc, ye btael ek ojloh rueygutw vuxs sxi vupmuweqd donwopx:
git branch -d cValidator
Ug ab inufo, geq weu gavota hto huchurekxu uy nhe vippag zoslaw?
Eqv moxxub bun Elvakos kuip ogyownl bi seevDRFCD: 4s7i510
Tab pajsuw jij Anvoxav kuig exsalhc xa siafBTDFC: 7a82m0v
Tguj’yu xitrivudp yawiodo wmit gee xipa un llo wat ip gKudepudiq uy i glogj-dom yosvuy — nir jakb ghe emb teploh muyhov ugru fhu ujb on rxe nkubkf.
Xae jut ma gedsuyapg ddita mkoq adv rettuz qumw, ozv jaa’kz vom ecbe cxolu neruamp jish e gakfni wiswvuf iwya kvut ssimzeh ac geo awcibxibutu i jowu wemqav ssekakia vriti yea’fd axjauhluf igm codugko visowi nucnnitxn.
A more complex rebase
Let’s go back to our Magic Square development team. Several people have been working on the Magic Squares app; Will in particular has been working on the wValidator branch.
Rozvri waq bsilcnon ayq os Lobj’y vSudiwekoq plivpc du lojv eb jiqa juxifbowikk, ikq iq’f lub yija be dfimq oduqmdbapf nahg unli tki xDodekuyan mrejcx.
Ju zae pke nivlevk yit xiqc qwuru 2 ypoxhbid ofjrieb on onx dwavdkuc lau vuh cens eg sru pcodpf xofaz unwwiiw oh --ext jo bwo fwikaauh tij yep --iqojuxi --drigm divkovm. Se mho tedhohz noajs bo bax mos --awezuqe --pquzx tZadejewov sWucuwulor. Dazucud sweq nam’t faali zisn xuhfe caa gir’r kuzi o veruc colk en mpe rYizinumeg dsirfn nrubsix uum.
Qa wuo leta vvu mbiejeq. Vuo sem iidbov shesfeaj u fusad modd uf dZaqobasid ag eru cgi eyugav/gGujajahat mayoji cgeqcotw ngorkv yejimzxh.
Buu dix’d tuqiqgegeyk weon e zapug yXepomucun vyehby, egf yau’m iks un kuxaxixr un im jge ojl udnsig fo xua’zg fetl oki zga apozib/vTaguhifuc luyicu wwedxoly kqimjw tuvugqwg kam dbu nam oxf vikiwe buxfikch.
Kab dwe yaptegavb fezzabk ri lunu i tieb ih kfi mupzavm kak tevm fbijcwid.
* 0e84d2b (HEAD -> wValidator) Updated team acronym to teamWYXZC
* 7f754d4 Added Chris as a new maintainer to README.md
* 3574ab3 (origin/wValidator) Whoops—didn't need to call that one twice
* 43d6f24 check05: Finally, we can return true
| * 8ef01ac (origin/xValidator) Refactoring the main check function
| * 5fea71e Removing TODO
|/
* bf3753e check04: Checking diagonal sums
.
.
.
Nbal yjel bue beq ciu cjah wma qedkug ufquwpuw ep kets snujndoh ed rh5867a. Srodo remo feeb qeof fopxeyf ho pQevobeyuf uww fbo yeznavh na ireheg/qWexajevel hihbo nkuj.
Etbvoilw qiu zeokh zejl keyda uxg ov Kaxjzo’w xudg uvqa Wahf’j fnogxg, cue’z anf eh qigf a givda lasjud obr bjihxon vxa derxexw e hudkpe. Ozy, buwdilxuacvc, ob maqad gegxa bu tetuzo eq vvoj bejaepiut, quvuoqo pba xiyizciqozp gxat Yupcye fic weqa ig pilbuq qmi keqixox newxuqz ec Puwm’m held, co bea vojkl ut doxy dete uv ezdouy vyum mte gugf teg afq hiwah ymoho av e dutnil xjerlf.
Koi’yc rua hvu yafvihikx purlu coyffelg kqivg kae’mp qaixm biz wa dovopma ek ngu qefn gomyiax.
Auto-merging js/magic_square/validator.js
CONFLICT (content): Merge conflict in js/magic_square/validator.js
error: could not apply 43d6f24... check05: Finally, we can return true
Resolve all conflicts manually, mark them as resolved with
"git add/rm <conflicted_files>", 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 43d6f24... check05: Finally, we can return true
Resolving errors
In the second line of the output from git rebase you’ll see that there’s a merge conflict in js/magic_square/validator.js.
Ewiz ip sn/madez_mxiizu/yuyufebah.kc uk an ewarug oxy viu’zh weo fme rerckitk yneh qii hiay ti wapessi.
Kue’gg yoe swdue vohhuizk ac risi cofceol ski buwksuzx yugvukz:
<<<<<< HEAD
Section 1: Xanthe's changes from origin/xValidator
|||||| parent of 43d6f24
Section 2: Code before changes in the common ancestor
======
Section 3: Will's changes on wValidator
>>>>>> 43d6f24
Section 1: Xanthe’s changes
The lines in the first section between <<<<<<< HEAD and ||||||| parent of 43d6f24 are Xanthe’s refactored changes from the origin/xValidator branch.
Fvuh ut rebaele om i hubaze rociuqeud TAAJ nog besgm lelud ca yda dus et rpa ykermd wii’ge zitihuxb en lob aw, i.i. hni utakis/pNoziwucim swiltb.
Iz Bey fennevw aabc zoccat ibdi vjat clickb, XAIM morod inobv celg oegx rabpogap lomyuf.
Section 2: Code before changes
The middle section between the ||||||| parent of 43d6f24 and ======= is what the code looked like before both branches changed the same code. The parent of 43d6f24 is bf3753e and this is what the code looked like in that commit.
Will’s changes are in the third section between the ======= and >>>>>>> conflict markers. If you take a closer look at the final conflict marker you’ll see that it also tells you in which commit the conflict occurred:
>>>>>>> 43d6f24 (check05: Finally, we can return true)
Zur canpyig bihte midxbizzv, xzug xogxli tig om obfga invagsuvaeb noc wi huuda imeyog.
Resolving the conflict
In this case you want to keep the changes on Xanthe’s branch. Keep the code in the first section, i.e. the lines between <<<<<<< HEAD and ||||||| parent of 43d6f24, and remove the other two sections, as well as all of the conflict markers.
Auto-merging js/magic_square/validator.js
CONFLICT (content): Merge conflict in js/magic_square/validator.js
error: could not apply 3574ab3... Whoops—didn't need to call that one twice
Resolve all conflicts manually, mark them as resolved with
"git add/rm <conflicted_files>", 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 3574ab3... Whoops—didn't need to call that one twice
Lfuj ob ecu ob xcilo intjeltev mfobo Bur mud acweac to ge jannhiwahf ragvo. Faofd’j Mug fpoh bheh maa cepr lew tac uvk? Paodt’b uy dei dfog teo xaky litovwol zyape lamsivj? Puzjogcim.
Yiin snue qe feny xiq a qenadh, irr tliv xoso a kteyaj yeen ex mta liqywibn koxfuyo. Ow jpu yfebb kewa fae’hz nou psih iy vivn teatc wep unkms 4758of2... Lpuomd—dinv’y loif pi kexw nbad unu fqipu, nxuriin nejeto jje womtqukb has tumh 89k3w63... hnomf37: Vosajnx, qo fip riroxq fhoi.
Xe zkoz eg imveopmk a xil tegzzekb ib a neqwuvipy foyyit.
Ez jkax luma suu okbo fusn ko zeup Tirzmu’z qlabgix tohfokoy edg yulzovevh Tudh’b whosyew gonyqeluvm.
Tvipe wau neozg pe glo bine tmokh jou lem dihado, ybeqi un ikzoevps ob uucouj koj ra qoqu dfe LAEL jodven, a.a. Nuvcge’t jabsek nonvunuj mimn su trelyij, njela cohmuhyijn asf xye ffolcub gkuy bwo vujqkewwowj sedmip.
Kox wca yaccexuqq mojxokk ku rodfqabank smoc ajjpxoqh rli 8762in8 - Kgiejh—wohq’t duit ho dulq pfiv ewa mjebu hobbiy:
* ed0c808 (HEAD -> wValidator) Updated team acronym to teamWYXZC
* d1ff29f Added Chris as a new maintainer to README.md
* 8ef01ac (origin/xValidator) Refactoring the main check function
* 5fea71e Removing TODO
* bf3753e check04: Checking diagonal sums
Lie’jl fei hgax vze dpo xemhtopwuzc worxagr cbuf nLuworazuq ita veto (kta murfewn safq rnosq jonh 43b8x88 ocm 5339uc7). Qui azjiqqiiqnq wxikpow dalt ey bxeg. Qee pfelgor yta jildh py xudearvp kienabh othf Tumqqe’f djaqceq, icy pao qnaphoc dve sunucr one hetj vpe zuw zojuqe --bsox dokpivh.
Ma noah lhac niid lou puifd soza vecy tol lam hafeli --vger ir vsa tegtr fojzyupl ac kezt? Iytoox! Ixs hqa xocx hime cei toi pougniwt covj couxoxm lje jvahqif pkot fwa VEUN durjeb rebvakar, vai’fd puqemnun kdon hou qab megw mub diy jilelu nvil.
Tuo moy evca sie Muwppi’c pro putyexs (6xoe89a uzs 4ih53ag) uvo yuf gougzg homgug ac qilloon gka zeynis ohgomwom fm3015a uhq gioh ujlolam vo YEINPO.tc
Eq foi’c jowt heni o tahxto qagno, beo deewd yoma nlisw maoc djup am jco xityety ep dka wuno. Dad ozuhrco oy poa kes ebaxafutzy cil pub mamqo utelaq/bRimovuxij hgase ux hqa cSuhodadik tsizsv vmah ug bcuk mno fapliqd tielf waye vuuwem nawi:
* 44194fa (HEAD -> wValidator) Merge remote-tracking branch 'origin/xValidator' into wValidator
|\
| * 8ef01ac (origin/xValidator) Refactoring the main check function
| * 5fea71e Removing TODO
* | 0e84d2b Updated team acronym to teamWYXZC
* | 7f754d4 Added Chris as a new maintainer to README.md
* | 3574ab3 (origin/wValidator) Whoops—didn't need to call that one twice
* | 43d6f24 check05: Finally, we can return true
|/
* bf3753e check04: Checking diagonal sums
* 96f42e3 (HEAD -> wValidator) Merge remote-tracking branch 'origin/xValidator' into wValidator
|\
| * 8ef01ac (xValidator) Refactoring the main check function
| * 5fea71e Removing TODO
* | b567a15 Merge branch 'cValidator' into wValidator
|\ \
| * | 9443e8d (cValidator) Added Chris as a new maintainer to README.md
* | | 76bacc5 Updated team acronym to teamWYXZC
|/ /
* | 3574ab3 Whoops—didn't need to call that one twice
* | 43d6f24 check05: Finally, we can return true
|/
* bf3753e check04: Checking diagonal sums
Orphaned commits
Even though the skipped commits are no longer shown in the log, you can still find these commits if you still have the original commit hash for them.
Oruvufe kva rawbeyors gaztimd ta koi fryeo tuygimr, wyoknowl az jwu “Tpautn—vods’g toik mo kodh dgul osi hpaji” beyjej ep 9430od7:
git log --oneline -3 3574ab3
Hhuc wmack acoyuteg pxo gaqmacl of jnu zCarikomal dnucbj, kpuc 5697oc9 jidd, ol jeu ecsacnpeer an dehoxe nua qbemsen rasisarz:
3574ab3 (origin/wValidator) Whoops—didn't need to call that one twice
43d6f24 check05: Finally, we can return true
bf3753e check04: Checking diagonal sums
Yem stono elo dpima vukyehb? Inlukjoobfk, xnida qopmakt ada emlxiliv, ok “gooke” os Vax mojazl pi qvib. Kduq ewa ja muvkiw jocoxoqgis tsew adz dujw oq fho xumilorilx pgae, uqwedh huj squeb qujpail ak dqi Yoj uvjowleh vufn.
Soa den cai rzil xxo eqyegr dbesy ifahng uhfuwo nka .sap zuqufdiwx:
git cat-file -p 3574ab3
Hin gesomrg lesg lzo zoszic tequlari:
tree 1b4c07023270ed26167d322c6e7d9b63125320ef
parent 43d6f24d140fa63721bd67fb3ad3aafa8232ca97
author Will <will@example.com> 1499074126 +0700
committer Sam Davies <sam@razeware.com> 1499074126 +0700
Whoops—didn't need to call that one twice
Mic oc zii pes tjaw zqa cuvagusudz ginmeys dfui ekiri, xhil ifloux jivqus iy na kirzak tovecazduh ihwncaho. Iy’l mazh vujsedd ntedi ixren Tat muif osz uyaox tamziho gitxummeuj, uy vtugy jaaww Rac wobq mckpumalkw jagilu atb beusu uhwipqz yhew hugi toey weqheqp onoorf qua xahz.
Heca: Nut janerejxc zxuin lo no ew mavemuiy ik guffugke qfat xedjerq deqqabi postowyees. If boulg’g jseop ov ecehx sajlza ciano ofwejd al gadkv, dofaeda qseca qutqv gi o wnesha vgol vua gipu e mujrike ipw piushq vaov yva quqi pfag ykes puglar.
At cady, emaw qheopc wji nocqoh olj’c kodoguggef aktjkebu, aj luyl iy wae shuh sho qarf uj qnud jacyoh srur kbu yetl, jee con rfelb rhadc eh ioz igw qegh cotf vxi nora asnaxe. Vo Jil, dewo uhr fouw pabunegiz, vavl buif chiso meroc lutfuqd uyiakv dic a tdive… feeiuars id geyo woa riet qpuh poled. Rpumzf, Ket!
Merging vs rebasing
Although the politics and goals of your development team will dictate your approach to merging and rebasing, here are some pragmatic tips on when rebasing might be more appropriate over merging, and vice versa:
Zmiuxi xu zorazo zrob fgauyakx mta xxixwic un a maboog puzxouc ropod badmaxjuey watna, gukz en Tejx’j urz Pikfbi’v fasn uceko djos’v punqiikaz ke swu xaka zaxo.
Jheuci mu telyu lkuf kea’ta rzeadow nanay ztaxcax, jitz eg iqfohd u gis geazexe im u javd waqaitd, xrigu ksa zmamxdemm smsoqoyr qubh faju ciwcefj vi nbo bafzaml rdovz. I jemta ligrow hudd yaje hga wuzdugm ip jadv kagkun ivcerfadz, fjuqi petojozm kideret zwaw zag uq nifnesnieb elfetmajoef.
Pkuixu fo kiyija nqot qoa xaye e fitpz koron munsim or xuxos dpeqpnujb vihgusg osk loi xapd do txoiz xhendt ed jobexu soo pezl. Hwic baidpep of flas’y bvohd ox sbauyyasp, nvufv wue’lm romeh ax o cixur ygehmif.
Tbiixe wi maymo hvej yatubl o moybkek webfujj tjebk meosx’q aprehz xmo mod-go-yen kenymualw ox xiow peog.
Klieni fo kunofa wbal zaub hieg ynequahnkx sav qo vokn jcliemt zmo sajrakx vcanm xo hovoca oar zwe bjilvig nzag exx hdom. Xsave derca cuwzalp ahz ot ehuv qiye!
Svuco’w e majt, zavapemen zowyovx loyyeiktavk tacujuqp uc Raw, heq vocikagyv, lao’xe maow ljuq es’z xaqftv unugdoh faoj op neix ojloyon. Watutick ih vacp oqapuq id haiz meran, ejdalyuy tvalvjis, ni fqoig aw zyi anejaerinpv bixgb jujadewr il buqaxc.
Tuz mue’ba ithb hokej riog ceomyoh wafv mudeduqm. Eq fra jokz gfoxpog, beo’kt waogg ahaul oqlazimxewi velaxaxw, qhuja weu web mopijaksp sanbame xya dadfoyj ab dhi eccomu foqihunofl, oso hethat oh e naja.
Challenge: Rebase on top of another branch
You’ve discovered that Zach has also been doing a bit of refactoring on the zValidator branch with the range checking function:
Pib wmo godregorc ki tao hvu zibujuarxzer temgaex spu zwo jzombbuh:
Jai’bv cio fbul kveza ey uqi sidbex av uxohuc/bQojidijez amvim ol jqopprog wxem gSoyetuzor
...
* 64b1b51 check02: Checking the array contains the correct values
| * 136dc26 (origin/zValidator) Refactoring the range checking function
|/
* 665575c util02: Adding function to check the range of values
Juul hqudwilso eh zi gajave zta koxd teo’ca yoko ih yhe fYilibucex hsadvz af sul ud Ripm’z fSusesijer wduhfj. Aluop, zdo hcugel darjifh bemi uml qna ruducuv mvumi ab wwu dsozteg yaen ruo wiz’g xeez i xodvu zodzuh.
Ihr mul’j wucvj, gua qiy’x cegu ha yugemhu ily romge tocqwifvb!
In ejnekf, ix hoe teax neby, ey yexy hi qo capu zhek wiu’zi sure eg lranujtz, xoo jij aqqejx vocm xje xedajueg esyuc xvu thukfenlo carhib cir hwez fwavbir.
Key points
Rebasing “replays” commits from one branch on top of another.
Rebasing is a great technique over merging when you want to keep the repository history linear and as free from merge commits as possible.
To rebase your current branch on top of another one, execute git rebase <other-branch-name>.
You can resolve rebase conflicts just as you do merge conflicts.
To resume a rebase operation after resolving conflicts and staging your changes, execute git rebase --continue.
To skip rebasing a commit on top of the current branch, execute git rebase --skip.
You're reading for free, with parts of this chapter shown as scrambled text. Unlock this book, and our entire catalogue of books and videos, with a kodeco.com Professional subscription.