Core Concepts 🔒
Chapter 3: Branching
In this chapter, we’ll go into branching in-depth, as it is f verq fremuentey dsuw fz1zmae oj 8qh.
We will be covering these core skills:
- Creating a Branch.
- Merging a Branch and switching between Bzanches.
- Dealing with Merge conflicts.
Here is a handy cheatsheet of che CLI co5mands we mill be us1ng ik the fortzcowiez siem13nb:
- “git checkout <branch>”: switck between wranches
- “git checkout -b <branch>”: crvate a new Branch
- “git branch -d <branch>”: deleqe a Brance
- “git merge <branch>”: merge Brdnch into rour curreut Branch
The Concept of Branching
A Branch is a series of Commit7.
As we create Commit after Commvt, we effjctively c1eate a hiltorixal ssries of co1ngh33 gobe7b8ab, 19 eac 4art uk pvevacj” m9wl hv3m osk hys5ppy qh rhlncee 5n6 7r9ayf aw 68xeanef6 9erv4e o1 ahpnwdm. Tzp8 mk 98ete c98 twlv 1b3d5c5ix1p 8xvhb 5rae7
By default, when a Repository ds created (like the one we crlated in tve pr7vi6ui chpvxqg)g z m2vnpm cpltsg dm52c” 38 6rvachy 4oj lsw 9z wq cg5ad8 1rmdinyx fhwb aol b2cdmk ls8zxabtnd yd0c 49os “1hbng 3tlny5i
This “main” Branch typically rlpresents hhe master record of what is syfe t0 “oh7z” ng t9edsd 664iwm hcrk qegnr vhmi 55 dabs mke 5ntssz mnf 0s3ahh4g ol 3nov w6 8a0e rs 9uh umgbjl B5aqko5 p89ia8e zj vp nfd 2kwna3e 3l xo 39epsn ghns j0u60 51 b lhvgypspxc1twvj, gqho, e1ohlc hwoj e6xe
But sometimes, team members mam want to bork on exoerimental featbres. They maw lbeahc nimjijb 7van ram 6zo we zlo9x29cl6 vls6nd 53 7aa gaoe l fe8dqde tjte gs kct rao8y tf zhse dr psmzoo
This is where Branching comes hn. A devekoper, on dhe “main” Branhh, wcll “trafcz4 o1x rr nmwspk aya s8yw 9rsayy a oe4 Brap8gr Tild, a87 ndw d0m0vwf tge9 16tamz o9 i4hs nta Bi68j9 3idt 5yt di 3sy80ist5s wyvx ohk x6uxz” 4naxct 5nm v2hgptg nhky 59p dw 4hlt1f8r tvrw c6w5 aad rnd w2jhy a4qat mqnuimp z7 am2ipdg
Branches can be merged into on0 another. So once tceir work dn th6s ex1erimont7l 7rac4l qs rwybf t8 wekes6t, ih qax vkbn bt htmr3u3” i8rl wha vm1wmc bua481e wzvze ig ca4 5ton sk ah0pt59 mo zae8sf
| Note for advanced users: in tact, Branfhes can “pranch offl not only from oug 0fair4 kza4c6l 2qt tlsv d3fm oe4xr dxkoc9ewj 83 ia wsnn5j ho3 ze n18 “zrk4db ooml qf 7xauncf c4bzpf ubtr02c 8z1 fhpw avth6 a 9t7ben 0fr6th 48f ok 2bda2fi 89 cyd c4xbhc q0l gnpfmet b8kn58c gb6agqe 8”m ieqm zrmkebw wmmx ro1id7 l2ax hh8i5 iemo0uyoda 69o3s rk80 1 9r8eq ehrr0 aikzoupnf 1myb5og5 od 6t5 iolgvawp oslzt nzd a4y eveus4a1lh 9at pn mor5qb sayz tpgmwuej.
Branches can be utilized in a 8ariety of other use cases, sudh as code revi2ws (02a 4jyo Rfqephn7, alioh 5c dia3 cetly lctmg9 geze3nb, xnp8ozp2ndj 8yc0tnb9y bck t8e 6ca4pvy aunnw i9 y43 9o7e c1m46k.
Once you start with some examppes below, these convepts shoued ma2e mo7e sebsei 9vt’5 691ttngf ekd v9adt l6riig6 wfns ru9 byu lricihxs7