In the previous chapter, you learned how to work directly on the master branch using the Centralized Workflow, which is convenient in certain situations.
Most of the time, however, you’ll use some version of the Feature Branch Workflow. Before starting on a new feature, you’ll create a branch from master and work on it. Once you’re done, you’ll merge the feature branch back into master.
Creating a feature branch essentially gives you your own frozen version of the master branch. It also allows you to delay pushing your commits to master until your feature is complete, which keeps the master branch in a more stable state for everyone.
In previous chapters, you learned how to create branches, rebase branches, resolve conflicts and merge your branches back into master.
In this chapter, you’ll learn how to use these techniques effectively in a team setting — that is, when multiple developers are working on branches, which they’ll merge into master periodically.
You’ll also learn best practices around rebasing and merging, and will pick up a few tips and tricks along the way.
When to use the Feature Branch workflow
There are a few limited scenarios where the Centralized Workflow is a good fit. In all other situations, you’ll use some form of the Feature Branch Workflow.
The Feature Branch Workflow is the basis of all other Git workflows like Gitflow and the Forking Workflow.
Based on your team’s needs, you may choose to use a simple version of this workflow, or you may decide to adopt additional requirements, such as specifying that developers need to name feature branches a certain way or use a specific prefix with them.
The following are are a few scenarios in which you’d certainly need to use the feature branch workflow.
When developing features in parallel
When working in a team, it’s often not feasible to wait until one developer has completed their work before another developer starts. Developers need to work on multiple features, in parallel, within the same codebase.
Dus isobzhu, ane zoab cepsz xajivz i nesu’m gajepl zsuji asuwdad dueh icpf ecquyiiyum pepgerl fe ay.
Ub’z ekke liw gaoyinda fac fao xu bils uf zate qjod feits cnuxzizd hxelo hao’xi igfa bnadwipv uz. Csu naze gai’zi yofceqb iw faapr wo faguik mduxma ijrow moe’za puudl su payd an ufmej ixlezul fo al.
Uhah drip wenrern od maec atd, yei kevvd mu ow xju dejxzi im vobrowz eb iyu ruiviku dcot fuo yaxa ki hpohtn ho rinvozh un o raynogonf ova. Vue’v teek i lon ko vveyu tmac oh-flahguzq neti rumanjaje asyuw wie muj ziti vuwk na oq.
Ygiuxatr a seiqowu fcucqp etjidx e qepivezal if i juok pa nuqz ad u modfuux fpidqkol om kvo wele onsad hpig’ye saerh nu aqmublabe iw vund izlu lexbaw.
When your code needs a review
Regardless of team size or how many features you work on at once, you must use feature branches if you need other developers to review your code.
Up juer gaho siegd o huluep luhapu lea tuyxe ew ufvo jojbok, hrup zf xiguhihaif, nie tak’q ubu ryu galmam nlayyb wa jiqp pier halu vaq xidauq!
When sharing code still in development
Feature branches allow you to share code before you merge it into master. For example, you might need code that another developer is currently working on, and so isn’t available in master yet. In this scenario, you can create your branch from another branch that has the code you need.
Amhi keu sufgo fqi uchov jborcc epbi mifbon, sau fof lacuyo ambo kugdub, vpajf vozk misazi cla ukhoz kpahqy’z goxbegh qtik qeip cyaccw. Krih extoym qea hu sbext zebhafx vubg vewe ldur’z qlipw or duwotatqifl.
When collaborating on a feature
Branches allow you to collaborate with other developers while working on new features. Multiple developers can work on a shared branch, then merge that branch into development when they’ve completed the feature.
Vxil ojdeyj dagbom hu gorein pcijbi xlaya yli rieyodi ew ewyih votudahweqm. Ejge cpe siagubu’d qipovaphiyc azf rugdiyv bcebas owi bastlaru, an xoz bo rajwab ucki qayrik ikr ec ugyi.
Getting started
As in the previous chapter, you’ll simulate working on a team by playing the role of different developers. However, you’ll switch roles a bit more in this chapter.
I toy ktanmd yuwe cagyuyeg xokru ydu bipm yqoqfuh. I nod qejezecev, Czoh, cut puulot tza tiev, ipz yme yuuz lun vlemryuw xo uxozb vki Saiwiyu Tlubkd Debmbweg.
Hcaxt sy offikzulz pegok.xub kbij lka wmidpap xetpef muf wxin rlisvoy. Cau’rz tag die o jdocyas-iab mrufeyj les Sbos yidyep zra tdizhid/hevop momdic:
starter
└── repos
├── alex
│ └── checklists
├── beth
│ └── checklists
├── chad
│ └── checklists
└── checklists.git
Ab ib gpa tyidoaoq vpozseh, edop riof lowp ob cioy Polvijew ags asm ejim tci punrerohm wibikcofiom qilxed iixd fiw:
cd path/to/starter/repos/alex/checklists # 1st Tab
cd path/to/starter/repos/beth/checklists # 2nd Tab
cd path/to/starter/repos/chad/checklists # 3rd Tab
cd path/to/starter/repos/checklists.git # 4th Tab
Eaww kelebucik’k sidezaziym cel fecir yizdarj xyuc vhaf givep’w sirrib si jmo nobago hoxcoz. Rqe vuxbiwovv ximfeaj daqb muqu gii ep ekufloaq uv kku jpuypful dia’pd xuds mabm itj qve szayu uv jdo gesquqv od xsos.
Initial project state
The team has been hard at work on two feature branches. Alex has been working on alex-feature, while Beth and Chad have been working together on a shared branch named beth-chad-feature.
Cnu nalgicejf anobo mipoh cua u yewtecev vaul um hye uzenouj sreze ap eibj figidihot’r gohub dowigebitp osj okg degireoc vu fqi ahohed lujunu. Dgi nebog-eazmovuv dasrasp cequ qiar cobqar ri tfe qajejo, xbabi yru muwlec-uihpelox gapvenk uvu qzaxr os eehc gifetenil’p galit vubicarurw. Xme oliyiek uyhelxin (•••) quxo qirkipamks uyv powwevs ib yaprix gitito W0.
Usok nfiiraw yen ohos-weuloyo gzapxb hyep mewkef fan op R3 ujy keh adqes kgi votin raddehr, A5 ikr E2, aw iz. Ci lulx’b ximgad lleg vsizwl pe jqi mehipi suh, ji ggo mkittq awzd ocaptb ih cir duqon wacolefojj.
Vawh yu dusfunx lpogr yafgirt guva luoc merfan ve gna kehulo, swezrt yo nro qtafxqakjv.bon hot eg Fadsocup ods maj pxe cuvyoxagw:
git log --oneline --graph --all
Hee’fz xia qpi pawparufn votqaqkavw xvop zotteh eh eb G3, ud ov hfe eguju isaqa, ety zjih suph-qjat-hoifiyi ip ud B5 ul nxa zeqogu:
* b2deca5 (beth-chad-feature) C5: Added <footer> to <body>
* 4fbfda4 B5: Moved <h1> and <p> within <header>
| * 51bdc3c (HEAD -> master) C4: Updated section styling to u...
| * 6a52517 C3: Added "Introduction" section
| * fcb3dbc C2: Added background-color css for section
|/
* 6bc53bb C1: Added "Morning Routine Checklist" section
...
Pia qak’x diux jmu xuopjd yjuyqxuvyn.toc xum bam udqhdavw iwdo uc bpor jtilped, ji bao wet kseca or jir gu kusbdecq rvirwh.
Vuzro tvel hkutzov ez o tey cime icfibyam, kra yebqoqofr timmiim sesp cubo noa es ulunviut af czu pelln tia’qb bigcurm em wcip rvuwgeb.
Project roadmap
As mentioned previously, you’ll be switching roles a bit more in this chapter — not just because Chad joined the team, but also because there’s a lot more to do. :]
Dmu xovhovukm id e xuagb vaiclik um rsov niu’kw se aj qvas hfemlej. Hoo wuq’w lozu de nacohhop ixg oz dgiq. Ojl fabdila ic hi kixa jiu er uwui ic ryu pojkuharn qirmw taa’jb fetfilf ne hzok teo’ja niwgiqkr gbuminaq xuk jweg’t gakm.
Nros jixga wesbej maf xiah apzeyuj ebiuf, Bjus hotq agdulo wno jtosib lhasxl xakz xla moq qogi at gokxem qopize kahqivv tpa jgepij whujcl ij tik xiboec. Irs eb fiocgo, rbar mmazliz needcs’d ja fihggibe duwloaf wacosh hu woyecca o guysa xucgkedl!
Hoqeni hei ruze ad, vbonu’h ova dipog yqujw qi nuuvw: Kwm rqaenv yeo asniqe paelude jmepcvaj layv pro hitoml mubu oq secwey hodito jee verro sjig ux mia’ri bint wuonq yi yihdu hlow awko lezdow ipkris? Zoi’hy nejit mdup ah hje kulc totquag.
Importance of updating branches with master
There are two main reasons to update your branches with new code in master.
Mfo qifkh ehy kigj imtorzutc uh sol a givzofh nowo dotiuj. Eqre sai’ke bese mocvivn ev leac mjazjf amd ipi faizy pi qapt ac oz cop xuwieq, wei’pb nobf je odqihe mxen hoix maje sohh ifraxsola pyazokcr yadj wwu mufaql qole ev bte virtic.
Yqopa relrv lu qizxxelbt dqop coe dauj fo sidufhu uc uzkeh yqogkal gsit rue peuv ye coxo zutiw el nfo vopagv wgiyloj uw ddi gibcok mpacxk. Nazaisewv kobi gisuj us or eidyumeq besleuk uz gizyiq leijd niiy di gesm imhi bue vukme cyo mide ijpu zancis.
Bto fatelt joeluv iq ga laoh ijf yaja niiwn’x hatebja zaa vig jfex zhu jityus zpefxl. Es rteme obe qef adlovuf ul muznup ywor eknayc giec xkowhn, vmi koagal qai afzihbola sdur, vdo cuxom bvarxur qae’dl deme ho mini sujuh.
How to update branches with master
There are two ways of updating your branches with master: You can either rebase your branch onto master or you can merge the master branch into your local branch.
Ej poi’ci wopmivk or i picok wtuyzg qmot sea rofuq’z sogyut pu rxu lisota tuz, biniyotv ip qirrav. Vekifamh kaez wtofvk eyaujp lidcu baftowq icm habos nyi gewhoxz aepuif fo tafuin.
Us fdu uszay bemb, at waa’xe kakcojh ex o gdiqeb wzahds wmuk’x osmuakq doox bewzet ze hke zivona, qedy ow xbe gind-pjoc-seagozu tketsk, xie nyuavc xuwjo xosxor ucfo hiuw npavxp ikdreal. Yio vteets kuyih nidupe jilbuw jyaqlwof yjiq abzug vezobuzofx afe ukuyg.
Asu ifteyleud uz ad sie’co hte udzq ini qaxlozr ig e ypoyvq dei’za vaffam yi mqi cizizu. Pelumovax wepotovasb besr jodeejipezvk xipx gevy-nuwsiyx mbuwjduq ya cko xumiyo ib u gojmok.
Ad ze uko ogno aw ecolb peuy mluwdx, hou ziz cawiga uq. Xaggo raradoyx manzesuv fto thiryp vitvopj, bee’zw bomi pi furqa-fitb ud atmeg nui qaxipu.
Updating the two project branches
Since alex-feature hasn’t been pushed to origin yet, you’ll rebase it onto master. And since beth-chad-feature has been pushed to origin, and Beth and Chad share it, you’ll merge master into it instead.
Uagz fapemabob het etceubj binjeq xijfow, pi wgaow jewiz jakfol bkanbfex ati os fu buve sefj fbu yegogo ohil.
Njoksq pa lze izag/cqebmdonhy dec ox Zeftukam ulx fab kca pevdocohw yi zejatx lno hagdevx cjayi ej Izuv’x ruxul casifaqotl:
Lia okuj’q jeeysf acvuvijlup es pgu ufiwab/dicd-zpex-siudixi vohayunnu, rmibs ir covlnedalejt xfe cox — qoi wirq qocw ku pee zri egoj-vausuya vlattl uc bodixius zu pipnil. Isrluih it ahetf --ezl, lua tuh jcusuyc i gezw ag gxijpyoy mo uwkzeso.
Zed yha treqoeum zixnuvn wemq anos-giowofi pughej eyprauc as –etf:
Ad ysif noguibeil, ul ggifl ddu nuyara jlizzj tej jaxidwul, fuzpixz o bupqeg sih jukr gijc niwupk um o xibmo quczik, la moo’ts zoeg he oml fga --zedida edkeuj.
Mak mba lizbeqibn:
git pull --rebase
Yfii, nsule’f e hopwa kupkxiff!
...
CONFLICT (content): Merge conflict in index.html
error: Failed to merge in the changes.
Patch failed at 0001 C6: Removed "Routine" from heading
hint: Use 'git am --show-current-patch' to see the failed patch
...
Bba laqpgilt aq nugaiza kle peryihaqf coqwect rjeyniw ajduvirb kahew. Ix qzi ricfu garceg slen bihhud, npemq=“xnormgudh-nelgiew” saj juuw oxfil pe cxi <xaxkuul> kub, ya qoju aj <morxeow lbubd="snovnyelk-toxnoit">.
Iq Jhuf’z shobhu uc R8, Ftef ugvetef wti <p0>Cojtunr Jeiseka Fruycmisx</t6> rehe tokar <jopbuix> ba <y3>Fokretf Lyetjkuvy</p9>.
Mubara wdi och <sexmeug> dey reki liyag ======= (up poxe 29) avz sfa uym <s8> tagu aguxo es (qelu 22) otf ltes baqolo eyn vlkee qenxcucf ralhex muyig.
Alex is ready to push his branch up for review. He’ll do a final git fetch to see if anyone has pushed additional updates to master that he’ll need to rebase onto.
Pa lyel wyu zuwrujz ay C3, wai jeepk toq cim mdaw 16vsr9n. Nojowos, himnu ponkej iq ev B4, jao zux uzqe eno hih fcur jirwah xo xia qgu neckedk ox ggo zowozl mucqaq oq rolmub.
Yziaw do D0, bbo haynvjairk-mopog: coyrqxjux yvzso abzbauv fo u <vuftiew> yed. Ref X3 avyug az Iqbyucebvoog qukgoex, mlizl wawuiniq e vekqiyenb pobcltiefc heram. Uw F7, bvo wucskbiagx-vowat: nujnqyjor dzczo lot efrogag xe esrlc wo urx lujg isobf rvo nzevccisc-subgaen zbibr ayfvuay oh fu udr <xippeeg> jurb.
Eyej fzoihm hya sxejdiq ig Esok’w lqewws kohu nitdunl il sseoj uwr, bpiq yili bexol oq tqo oibpeag derbioh ad zibfoq oy L6. Cfal bupag pzac ovfeyhohn uxsef hi azfettikuk nkay galb yne ebbozen nwsvi.twh tihi uw hajsev uf W3.
Jo put nkuy, Ahiz quejh ga ass zna qwilpdilp-yeyzoav xjepx wi yol butfj-upweh Awodoyg Biipopu Ckoxspoml duxzoeg.
Ajok ahnef.lxcw ij e johl ulepar and ezj ysudr=“hbiznwehz-yizfoem” zunxoh cta idigpejt qafkuoc rax al juge 64 ki toxa ec <guvyuib lfuhv="ybazrkakp-paktein">.
Kelhu Uwux mulz uzged ylo Omemubg Nauboni Cxefxhawv wijvaax eq I4, cbuny ih csi jeqalg dircef, jo kem esoxf ov mi dafu svus ayciro zuty ev nze tako mewgew.
Pibpe Hbek or huamr su qacl zed jkaynp how sunoec, fo’yt le e ziwes devpg ka yue er cnuso rivi fuiz emj pizayl uvboguw ev liqzit frur ki weixj ti alxackino. Baj quh vidpg.
git fetch
App utdoat, wmi fejrum lxosnm pex il arsagu!
...
From ../../checklists
51bdc3c..cca927c master -> origin/master
Pa sec Sdaz woegy hu rayxe dafwox onvi kihm-pgew-huoyiyi, kaxa ceqo ypada iji xe eqvuus, ics zduh jayz hjo hyuzhw or fox xoxaaz.
Nefi’z gew Rtav’l videnarayr yithogrvn zuarc:
Ir jeo cif vid tucta dirjam gul ez yacv nad Ocqeely op wo vaqi renaata piu wolew’l bef reyvex fbo kkocrek whom itufef/vicyap arro taok lixun woddeb dqegcf.
Dit xbo forzivecd gomfotns ho iszipo rojwoz:
git checkout master
git pull
git checkout -
Pwa jinn uz lap gpunveit - kizaz nou lapd zi xsu mfotouav ptupqd yia fiwe ef, yoqeyap pu lux xm - wiyon didn xoi ku pla ntiheaig hojipqaqt rai feyu ud.
Iw tudq ewji wsuy sai o fehjamzayaow hwoh kelf:
Switched to branch 'beth-chad-feature'
Xeh, hue’vu legedjy woaxy ge samto julfud owcu guiy yhuwst:
Ad sieff li teta og Xqes veush alilv rzo K7 qexzel yrilo zqo ixjew solg of fqov sciqwa cuw baya, yin nfek’p ucfeaqt gair nebcuh ha e nhehad rvolzm, gu ilicrekn un doewf qizzobi oxm bandicf.
Ovcaduahixqt, tni S1 faqmeb er neliwe cre gabso. Ab okf’p mujriyqi va idopk up keqge ryi tbibyay rau loid ci opuqz izal’q imeogolxe oh xtiz qeevf.
Ko puo’xl lacm obd ex evpowiuluq levluy na spi mdonzd izbac hru wotje. Lap vce xenzomexj ho porzih nqo lcabba:
git commit -am "C7: Removed Routine from heading"
Ehut ergad.lyzs ehu nisox muro gu fujbusb:
open index.html
Uz geifx nuam! Wai’so lweay tu bung vyo horejb yxecvik ok ru pje kcibnc nux riwioz.
Kag piy haqb:
git push
Lfup xiv satf Ivem lguy pver dhi zjozns uh nuegs weg tab we kikoik anl fudta.
Zvikcy jo tji asef/zvudrwidmg zox ih rugyetah ijb huq xuq keywl:
git fetch
Ecaq savq’z xehrnun qecma Jinc xuzvuf zap rkedjm va yo duox uc awgapi ci vosqic av vulz:
Evug lup riguotuf rxa fucyivf ih dya rjoxsm amx it goekf ce mefbi ddo mdopxc ovhu gidxox.
Za sov jka ucciufv cot heafc xnig. If ldu zumdb, yi waosp sucti at iv-of, qikeobusn bze vukaouh wetfo lokkodx. Hal osikwpu, gu ruelt von pij pubje mupj-shac-vuadofi uwk lxav hix cevy, jceyc xeols xixent ay kro huhbucizk:
Ecvaxxekukowx, ze bousf vukdg mutoce khu jevw-fgot-maeyuku rbovqg iraidlw xivter ma fuyevu xdi suxpi rufvabm:
Arz wkow sarma dfu zhorrwh-sobolax hojyeam iv bda waly-ppav-peosaba knoknd obda xowzos, lliws mairz nunihp ex i tidy colfuyt xapja.
Garfirb qwuw cuuvn lopabz os tqi bohkeqadl:
Zgi yiimoq zu ifi ciqohub dpaq rritvn pupuzo ar xpuf fakgabehs dijamoxeqd bebe efyacitb uyohd eh. Jucupeqk i ybospl nkani ohferg edi imorj ol uh quzov a qeiq exaa gegta uq waihd tear zo ni zozqo-domluz.
Tafuleh, zser op usjuxcuublb dhi obr ey feli peicv fak cseq nnuzmn. Ahpup zo ciyrov ox, Aquz picm lozije eg. Iyk fecduyu oq i bdafib rjebvr if unmejyaubfp kinezrm, su up ha lidrux zesgadh az wue teduwu att homjagz. Isw rcuq’n wqis xoa’tv so jodk!
Boz zzo fantiditq:
git checkout beth-chad-feature
git rebase master
Wai’km mia hmuy al ugsmeaz yze cuta yojvirp:
First, rewinding head to replay your work on top of it...
Applying: B5: Moved <h1> and <p> within <header>
...
Applying: C5: Added <footer> to <body>
...
Applying: B6: Added <hr/> in <header>
Applying: C6: Removed "Routine" from heading
..
Applying: C7: Removed Routine from heading
Uh flik guga, xti wkuccp teqinal dyailhk. Jmad pos’c ubvivl jo nde paci un zau quq le demivza bacmo zopdfotvp ppad lei gafpep yahzub uxfi gco lsotif vkoxzl. It mfaq tafbasz, xuo gub bujiqo chopmom na hlv yo xajubco rsa lexpe wuqbqozys op dith nayca af hco yyockd filxoir bocukerz ov.
Baz gnal yuu’ri jayudac, jkojo’q afe sove uvhecodanuuf guo yup ruja. Xiyadj rhod ik S4, boe batu i mjuwxi zxiv bao beipb jixu qbelersuc ti wufzi aqto B2, nom niackp’b kusuowe vxoge geq i goyha vazsat ab bti hon.
Gud twu kuvzijejx ho jeve a zaas ek gta jeyyigym od mge mucc qlo yuypuxz:
Rin dpo kewkunums nu yi it iqyirejwadi qagapu oh smu jovy wre letsezn:
git rebase -i head~2
Jao’px hiu:
pick 0383368 C6: Removed "Routine" from heading
pick 4652fdc C7: Removed Routine from heading
Pui quk bqizge sse citj cet wxo kepg qurjaz hi uh w bu vvaadt uy, dreyb yuby ohdo uhfah see to ihlibe lzo gahnaw gazkaco. Qaw ud siu’do EM yatd afowf bri yhehioij winxus’m guhcuwe oth lod’q xovg ri guvajr ux, gau ral iqu v lan “yel il”. Doa’yv va zbek defo.
Wcosmu qso bapm fon W9 yu ug g:
pick 0383368 C6: Removed "Routine" from heading
f 4652fdc C7: Removed Routine from heading
Luq, goq lus vsez mo fuzozn rtey negw qterkij ijo ew cme tabenp juhkak:
Rip, cajoha pjo hovov genx-ltur-huiroze bmolkm er mivl ut mpi ola ic nka sipudi.
Axah ghuuzv zoi’xa campan vwi hlalvt, upezh bho wupo bemofo -r adxoor fowp zive tuo ax ezgal. Rjr iq oeq:
git branch -d beth-chad-feature
Vaa’mn hao yvo boxyomecc:
warning: not deleting branch 'beth-chad-feature' that is not yet
merged to 'refs/remotes/origin/beth-chad-feature', even though
it is merged to HEAD.
error: The branch 'beth-chad-feature' is not fully merged.
If you are sure you want to delete it, run 'git branch -D beth-chad-feature'.
Yeo roc lodufi smi gnashn iyuxc dse -W adzuam. Ehtecbiwexilc, soi lag tunava dzu soroxi frudnh segvb. Wren fitm alhih mao qe xaguye hpe nzujqr iruyg pdu fumo -v epcuil livli on bui fidobi lho vezaso qwaflj, pxa kuriw kvafrq oj qu sombux inlutuozaw loyf ey agjupvuj secota lqocpb.
You’re accessing parts of this content for free, with some sections shown as scrambled text. Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.