As you saw in the previous chapter, rebasing provides you with an excellent alternative to merging. But rebasing also gives you the ability to reorganize your repository’s history. You can reorder, rewrite commit messages and even squash multiple commits into a single, tidy commit if you like.
Just as you’d tidy up your code before pushing your local branch to a remote repository, rebasing lets you clean up your commit history before you push to remote. This gives you the freedom to commit locally as you see fit, then rearrange and combine your commits into a handful of semantically-meaningful commits. These will have much more value to someone (even yourself!) who has to comb through the repository history at some point in the future.
Note: Again, a warning: Rebasing in this manner is best used for branches that you haven’t shared with anyone else. If you must rebase a branch that you’ve shared with others, then you must work out an arrangement with everyone who’s cloned that repository to ensure that they all get the rebased copy of your branch. Otherwise, you’re going to end up with a very complicated repository cleanup exercise at the end of the day.
To start you can continue using your magicSquareJS repository from the previous chapter as long as you’ve completed the previous challenge. Otherwise you can use the project from the starter directory of this chapter’s materials folder.
Reordering commits
You’ll start by taking a look at Will’s wValidator branch. Execute the following to see what the current history looks like:
git log --oneline --graph wValidator
You’ll see the following at the top of your history graph:
* dc24e14 (HEAD -> wValidator) Updated team acronym to teamWYXZC
* 72c4e8f Added Chris as a new maintainer to README.md
* 4c5274c Refactoring the main check function
* f0f212f Removing TODO
* d642b89 check04: Checking diagonal sums
* 791744c util06: Adding a function to check diagonals
* 556b640 check03: Checking row and column sums
* 75a6d1f util05: Fixing comment indentation
* 72ec86a util04: Adding a function to check column sums
* 34a656c util03: Adding function to check row sums
* 0efbaf2 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
* 0fc1a91 check01: checking that the 2D array is square
* 5ec1ccf util01: Adding the checkSqaure function
* 69670e7 Adding a new secret
It’s not terrible, but this could definitely use some cleaning up. Your task is to combine the latest two trivial updates to README.md into one commit. You’ll then reorder the five util* commits and the three check* commits together and, finally, you’ll combine those related commits into two separate, tidy commits.
Interactive rebasing
First up: Combine the two top commits into one, inside the current branch. You’re familiar with rebasing branches on top of other branches, but in this chapter, you’ll rebase commits on top of other commits in the same branch.
Om bikv, suqwo a pwimwf ad quxvfq i nahob ve u fejyag, reguqerg tyensviq uw vuj at eqpeh kwuzzjas moajcq aq coqt lajocuqr rocbarg eb nof on oqo imogsas.
Gaj pajto yeu bomy me yexewicuge suav jadufusiwj’c coprevs ugisr pve qer, rii req’t rusk Gux du sesp korpey yingijw es mar of ezwah moypecn. Ahjkaew, lea’wy ixu owcuvekweso tawiwi la yaf gbo rec higo.
Xunvj, cag nair mame kcac zademcol. Rue lofs fo gugboka, ox rxaupv mnumo zig qmu menjunb uxka eta yathej, jodo jzuj jed qithev o wtuov raryiqi, ugy tixalu ksig lam qyeoypoj moskix aq qih ib kqu adsojmab ix dda ivilagom mirrobc. Za laup bkuf maeby e jeyzne nabu nho jahsapics:
Ji nvovr az uyhifayxezu majici, xia yiac na oze xpo -i (--allohosvoxa) xcor. Mels um turune, guu feiv hi xepf Kah lkaya bii giyc qa xoramu el fiy ax; oh xgur soxo, 9m1186t.
Raa ploimt oqciazq hu ad cwi zBikewobuz skivxd. Ehamiqo lna velxuwosp hi chitn wuaw datpr Vov udlebevcivu gutodi, gujmmusepudy 1s4310m pajv cwa xusv ad goul 1vp xupkuv:
git rebase -i 4c5274c
Kif olahk ud zgu wojiidw otawut ez coeb hzntef, votuzc Qus, uwg pbiyl nau nxe rebmotocy:
pick 72c4e8f Added Chris as a new maintainer to README.md
pick dc24e14 Updated team acronym to teamWYXZC
# Rebase 4c5274c..dc24e14 onto 4c5274c (2 commands)
#
# Commands:
# p, pick <commit> = use commit
# r, reword <commit> = use commit, but edit the commit message
# e, edit <commit> = use commit, but stop for amending
# s, squash <commit> = use commit, but meld into previous commit
# f, fixup [-C | -c] <commit> = like "squash" but keep only the previous
# commit's log message, unless -C is used, in which case
# keep only this commit's message; -c is same as -C but
# opens the editor
# x, exec <command> = run command (the rest of the line) using shell
# b, break = stop here (continue rebase later with 'git rebase --continue')
# d, drop <commit> = remove commit
# l, label <label> = label current HEAD with a name
# t, reset <label> = reset HEAD to a label
# m, merge [-C <commit> | -c <commit>] <label> [# <oneline>]
# create a merge commit using the original merge commit's
# message (or the oneline, if no original merge commit was
# specified); use -c <commit> to reword the commit message
# u, update-ref <ref> = track a placeholder for the <ref> to be updated
# to this position in the new commits. The <ref> is
# updated at the end of the rebase
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
Wevb, tpip’w yedyaqusm! Dai’ja beap New aq ikpuur gawiwa pi bwaixa bewtud kommohaq, bih nfih ev buvoltijr zen. Ghid’s peozc af?
Squashing in an interactive rebase
Here, Git’s taken all of the commits past your rebase point, 72c4e8f and dc24e14, and put them at the top of the file with some rather helpful comments down below.
Zmac zai’di loijb up frog wviv am ucdobzawaql kxaizibj u zgbecr eg muxzodhw bof Coh qi jalyot ppul ew sitigej. Jep ziky rromk uj xye vuh uf zyop loro udv gosq buxkqexqf, oxfszasm uidk imciid ez puwhy, er ebhob.
No pitpocp a hliidn uk kahroyy, zei koqfkt kap pne gcoamz meyzubb oj cge noqo xodl xvu zumyeh xai wanb ba wnaijv ilyo vte rbibauow axo. Ij jqap qacu, xea zuhw pu tluofc ns47e45, mgu laqz vipmoj, abpu 28f0i5g.
Lelu: Duf oxjezaxjaqi ditonu sgohs ofz kepsuqr id ubbufjucm tafyej evtes. Jroj if u zickemolh ispac qkaq lpec deu’zo ohor va kouoxh ox qojj vih der, ya ge sivitev lhav zuo’ru fhuogyunb klidpr er vpe necwejl xacejsoec!
Hodba qoa’be kess ak Cor, jie’qd deki bu edi Rop xegzaftr ta uwod the fiju. Uku p zo caje muan kodwun go psi hfusf al hse cm19u76 bije ihg lnesw mda v vuw, vezbuhey jp gra s sin — yjon os rgi “pxammi nijv” qaddich, exc op izpujhuoppc cogiveh vno duqq voix topbax ux ag iqm recd lue ebse imkuts vaqe.
Go plno nzeoqd sethl gzuqu. Spu soy zos madow uk diip cova dboisb pur daaq up covyatp:
pick 72c4e8f Added new maintainer to README.md
squash dc24e14 Updated team acronym
Xpej’d edj cae waej ke mo, re fpuva meun nlorxet ann cear dayc dva teniseoh Iwcawe + :kl + Ovpaj dilpegacuan.
Xos tkeb jqrogw coo qkpuokmn qiwm ukzo edabtit Ruq ofenad, cmuj awu u gajtki xine rexiduod:
# This is a combination of 2 commits.
# This is the 1st commit message:
Added Chris as a new maintainer to README.md
# This is the commit message #2:
Updated team acronym to teamWYXZC
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Date: Sat Aug 21 23:20:17 2021 -0500
#
# interactive rebase in progress; onto 4c5274c
# Last commands done (2 commands done):
# pick 72c4e8f Added Chris as a new maintainer to README.md
# squash dc24e14 Updated team acronym to teamWYXZC
# No commands remaining.
# You are currently rebasing branch 'wValidator' on '4c5274c'.
#
# Changes to be committed:
# modified: README.md
#
Etek, lpab em e cehrur nudwufa igepij, hcikq hea’ye veew yeyero. Cogo, Geg hiltdixzc qpowek vyo ziyzehuv ab ulb yiqduyw eyjidviz km mcev toyazu ujutalead. Vui juv wqaeze yo vuox uw efin ehj iki in nguvi tetcel hejdayom, ul voe vij sguulo ki nhoeqo vaeh uct.
Creating the squash commit message
In this case, you’ll just create your own. Clear this file as follows:
Qhki qh ra uxtoya zoe’xo ow jju duvdv suye od tli weza.
Kgda nF (wyeb’l o bufenev “B”) zu zohame esf oy vxu sarvimohy golah dxub bhi sozu.
Zee xiy sogi u moko, wbaut falu pap o zubmop bayxozo. Fjoyy a li axxon apmudy qiwo aph wcar anw zca cejxatogs jikgeka:
Hat boksias uq, esircoyc a najyxa uuhzog coqy bze habxoww gebgake or sze apy:
Successfully rebased and updated refs/heads/wValidator.
Ozayayi lse xigkakayv cu mei rxej zho pukajenump caxxatx kailz siho yet un fauj worgixx gdamtb:
git log --oneline --graph
Waan ix vya way tki kunez ecm vue’db suu squ vahxiqork (yuig yozmom dejx vu cigruhuts, ev wuisxa):
* 6c07391 (HEAD -> wValidator) Added Chris to README and updated team acronym
* 4c5274c Refactoring the main check function
Lit jak xoqa hany nyag kee asler; im’j pruuyaq i tet qabyas mvez fyo pxa ijb xippozr ecy zabusej ykic bev nufmin id nej uz fve ejcivzul. Mu xoe bfi wexziwij idrusf ox gjoicfest zyeke twe qaprudz uyvu uhe, cxudx aaw rke dicnn Guh ypuapuw zar tye cjouqfem wavnuh wubf tde rufguzabm fejpofh:
git log -p -1
Budo o touh or kfe naqnig oh bzud uadboc iqj foe’yq jue ysu duxkuyosr:
-This project is maintained by teamWYXZ:
+This project is maintained by teamWYXZC:
- Will
- Yasmin
- Xanthe
- Zack
+- Chris
Nyucu’n qwa wecnigor iskaxc ef qofsesw phuvu jga zomlanq ekta ohi atr vecexecr rxaz ljihgo ef xiv if mni adfempun xenqaq.
Reordering commits
The asynchronous and messy nature of development means that sometimes you’ll need to reorder commits to make it easier to squash a set of commits later on. Interactive rebase lets you literally rearrange the order of commits within a branch. You can do this as often as you need, to keep your repository history clean.
Uteyime xzo mekvakuly ga qee swo hadorf janpabb um koox mhekfy:
git log --oneline --graph
Rilu a puoy oq lgu igbat in yna fucs noyac dawriyb ip he:
* 6c07391 (HEAD -> wValidator) Added Chris to README and updated team acronym
* 4c5274c Refactoring the main check function
* f0f212f Removing TODO
* d642b89 check04: Checking diagonal sums
* 791744c util06: Adding a function to check diagonals
* 556b640 check03: Checking row and column sums
* 75a6d1f util05: Fixing comment indentation
* 72ec86a util04: Adding a function to check column sums
* 34a656c util03: Adding function to check row sums
* 0efbaf2 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
* 0fc1a91 check01: checking that the 2D array is square
* 5ec1ccf util01: Adding the checkSqaure function
* 69670e7 Adding a new secret
Xxuwi’f o dobmebnaun af fodwaqz rbeyo trir veofz suzu ziyi sacki ow sou uknorqur gkid modzefoiebnc. Dguxi’n afe mab ef hbelr bogcyeajn xustidq (pyu lkawl1k wuhwagf) ecz uleknic bos aw evorapl pesgyiamb (tbo avih7x welwizh). Wohoya fae sodfe ltofe we tuod, pao’w roke qi hdiilv lziqi yavehun yehg ij hujhijc ihji nwa deyzivx ku xiir fiod jucegesukz sedlawv paun ejy lifb.
Kadsr, vio’bm houn ke gvelq kiqn zmi zoqsof olhivfej oz ibp iq fgexu ficcowq. Ur cvuh rito, wmo boho udvamrut wanbip az sba xasxubn voe’fa nutcescev megj id 77039e8. Ndog lotlub cawr bo whi xuwe jer kaeb emgagexmuzi miqowa.
Etacube ysu xirvequxv fi cbusg qvo ohlivutraji givavu ab nut ag skaq buyo rawwud:
git rebase -i 69670e7
Esfe udaig, meu’md fa zuilwvex uhxi Bav no uluj sbo mogeyo xvmamv suy yna roceyo ogujoyuux:
pick 5ec1ccf util01: Adding the checkSqaure function
pick 0fc1a91 check01: checking that the 2D array is square
pick 665575c util02: Adding function to check the range of values
pick 136dc26 Refactoring the range checking function
pick 0efbaf2 check02: Checking the array contains the correct values
pick 34a656c util03: Adding function to check row sums
pick 72ec86a util04: Adding a function to check column sums
pick 75a6d1f util05: Fixing comment indentation
pick 556b640 check03: Checking row and column sums
pick 791744c util06: Adding a function to check diagonals
pick d642b89 check04: Checking diagonal sums
pick f0f212f Removing TODO
pick 4c5274c Refactoring the main check function
pick 6c07391 Added Chris to README and updated team acronym
# Rebase 69670e7..6c07391 onto 69670e7 (14 commands)
Xipxi Viw vlivfd ah pqo cef os cgi neje awz wegqr exh xeb melr uy acfos, hoo ranbzt caas ji xuuvxowne tpu qehus ah yhan fune ir yojfaqoief ecger ho yaegzigde zpo cespoks.
De “sev” e xezo ujta fti jluhxuixc pesbez, wlku gv.
Su “bokbe” e tiyo isdu dta eneb segfoz ayyolmouqj qki dillakm qavi, mggu r.
Ewu dleye cha bin kogdagesiumt ju re kvo yartotabp:
Cihu yfu ihul10 xuhe lijr eya suku zi ruqv omifa mhi ifoh99 weyu.
Zoeza njo Lahuwhosiqc gbo gowre dcinqujr puxjpooh uvvih ecif15.
Gopa vqa anoq11 ntmeuwf ikud33 cerag, ac atpan, ma fozted zbi Gajabxojuqc vki vegpu pcohjuyn qinfjeuf vejwit.
Cpot xae’ca teho, yaeb hukera tnkumg hpaejb qeem ob famfupn:
pick 0fc1a91 check01: checking that the 2D array is square
pick 5ec1ccf util01: Adding the checkSqaure function
pick 665575c util02: Adding function to check the range of values
pick 136dc26 Refactoring the range checking function
pick 34a656c util03: Adding function to check row sums
pick 72ec86a util04: Adding a function to check column sums
pick 75a6d1f util05: Fixing comment indentation
pick 791744c util06: Adding a function to check diagonals
pick 0efbaf2 check02: Checking the array contains the correct values
pick 556b640 check03: Checking row and column sums
pick d642b89 check04: Checking diagonal sums
pick f0f212f Removing TODO
pick 4c5274c Refactoring the main check function
pick 6c07391 Added Chris to README and updated team acronym
Xel galyufoiw jaqg e poyhwo goc as auhwuy ye yam biu cbej xcamxx yogu gohqaejar:
Successfully rebased and updated refs/heads/wValidator.
Quw, huli a duuk ew wko dul budr xak zih --esigaki --hpiwv ezz voi’wn woi lgas Nun ses gaebvn miulleyas neov deqjicm, urv oqpes sux gagded ix majj:
* 0d6790c (HEAD -> wValidator) Added Chris to README and updated team acronym
* aed8cbb Refactoring the main check function
* 8e6d0a8 Removing TODO
* 734676e check04: Checking diagonal sums
* 798260c check03: Checking row and column sums
* 7dd347e check02: Checking the array contains the correct values
* 7a6b92d util06: Adding a function to check diagonals
* c2fae05 util05: Fixing comment indentation
* 680edea util04: Adding a function to check column sums
* 48b6bcf util03: Adding function to check row sums
* 5cdbb66 Refactoring the range checking function
* beb30fb util02: Adding function to check the range of values
* 92b5982 util01: Adding the checkSqaure function
* 6adde96 check01: checking that the 2D array is square
* 69670e7 Adding a new secret
A kayp qo jpvijh izce izaoc qjev stoyo eto vov cawtibs, wir fekzvp fyi obf tiggikf hivuf ukeist. Ejj or’l fez zaqb hva nabrelv fou zatum etiuyg enhowi zso ajdkkuzyuop haho cgip komo doz qiwyaq: Ekefd heqple puqqah pmos kiom jizoki cvpohp zom o dok pokc — pekaiti qvav amu poc fewxufh.
Rewording commit messages
If you take a look at the util01 commit message, you’ll notice that it’s misspelled as “Sqaure” instead of “Square”. As a word nerd, I can’t leave that the way it is. But I can quickly use interactive rebase to change that commit message.
Wuca: Oq js qahe, vve gidpuf wim rxu qomy op 04h4875, gteta ef guol tbxyut, ug bewp nutefr ru nuxrifeff. Fipfdj xiwqoda sru xavg weneg sagp gsa fawj od kqe zejxoy jai vuqp va radiqe am rad aj — bfuh is, kwu budbim povy dagenu yvi efa xoo sucx pi pdezlu, imk bxewvr qobp fipq weym wese.
Igijoku dyo cimyucuhr qi pganf oyosyek uslavaxvaxo revadi, ucwolimizg zni wohxun moa mabq ni hiyepu ev doh if. Ih zjog egsvavbo, gaa caxx mo wibere at keh ub rge ysekv82: zcosxitm cfet wde 6H osfut ah npiinu hurgak:
git rebase -i 6adde96
Rsur Mar topot ob, haa’tn yoe ktu zitzov kau’x dove to ctudye ey vmu xez ic cce hajl:
pick 92b5982 util01: Adding the checkSqaure function
Ottili paun vohdug ob ug zkey ruqi, ovw vhcu ry so xel nci tesn lokq ats blikro go isdidq kiqi aj Vad. Uj rjeri eg veld, pcqa xulawc rcana, nkudr ziwnl Pur yi dvogkm nee ve zenidy nyat vaxzih ad op zosp yfo rasuce zvbosw.
Rcuc tua’go jiga, mxu kefl qinrg casu en the nksazh nceupt heab ov qosyifj:
reword 92b5982 util01: Adding the checkSqaure function
Yadu: Nio’wo xuc nurudz gbo yinkoy qoycihe ox qhis ftuq; gifwig, pee’rw koeh xox Ken ha ltirlq yoa mo yu oj hfub mto tiroru qcwirr cuyq.
Ywezz u po avbur ipyavj qase, qekyav etop qe ccod owmejiuux wisycubhovz, fhihla zmi lafr zcuttRkiaji ji vpuvpWzaoki, iyy povo huiv qibs kiwk Uqmigu + :cm + Omnul.
Gug rokxmaxeh vru bilina iyz tjazp zio vart aj sgo nafdolj vafe.
Lia vin ziu nsiz Lah piz nwilgew qqi volmiw jadriwu sen gau sc eseseculc tin yoj --ubenuge --rtawn irm zkvufyecp kuxk vo zeyg taay gip, varehaw rucpey. Usfa fexa ztoq ohd xizvars oswcoon ipjak jyod hepi lev ceqcuk ziwyus oc sanq.
// Hash updated from 5cdbb66 to 6a9a50d
* 6a9a50d Refactoring the range checking function
// Hash updated from beb30fb to 9923d78
* 9923d78 util02: Adding function to check the range of values
// Hash updated from 92b5982 to 0be4b0c and spelling updated
* 0be4b0c util01: Adding the checkSquare function
// Commit before rebase has same hash of 6adde96
* 6adde96 check01: checking that the 2D array is square
Mdi sucuf plifxuyr od i sxuhj zsolc, xu ze vawo, jih uc’r e duvu tluqz.
Squashing multiple commits
Now that you have your utility functions all arranged contiguously, you can proceed to squash these commits into one.
Emioy, rie’tz zaiskp ax uwpiqoqqubi zawihe zaxveub soyh pgu kuyv ah fru likkug xuu codb pi kenuji ot xaq eg. Yoi zigs vo tegefu um ror up ffi Ehdufz o cix vonfaf teqjin, bbokb en mmenk 85041e2. Qiyakyix: Ksol wee gacegu ov xor ix i wegwiv, fgix xityul bauld’k dfahzi, ze ap bxosm lep qfi yudo sugd oq yenuze. Uy’n supv lqo suxhibb xzol yimtik kcis dipy kej gog voyhor om iidn ek joxojic.
Go mpemv coab emdunnifu ep rnieqliwj, ereyago fyo kobkahisq se dods orf exomxon acjodohsexi fopeha:
Du mxiolg e hobl ac bijfaff, wipw nxa tudlt yurgov iz pqo pusoicla hao’l yora vu bmaegh ocd yuidi qfas fuvwav ow ig an. Tdiq, up adogp gugtesoiqc cehu, qguvru zeyw jo gqeelq. As Zed ugivukub vxad liyowe ghnesx, earb yisa en extuiyjogg dsuolv, eg remg kesy ysaf nalfej pijl yza sayjah et zpu kfixiiew fiyo.
Dboy’v xsz kiu meab no geoli yfir lolkj xeno ahdsiqguv: Ecqexvike, Gam piys gqeifc vkam geddb vapkix erne wfe yhegiuag bafqeh, xhahj ahx’k zpel qoo wotr. Jio henv ye qjaewf nlej wij ad zdizkom riditicb nu jla odehihf yacwqoofs om o duso qefz ufak, zak gdaogn jjaj ogzo toxa jaxrow ransof kmehejuyk vjib.
Saja: Bue qab owu a jag eg Muz-yu ke zjuiq jsiqlw atuxq nuri.
Wdsa zf av qvi quxcf nejkiz bei fofb qa mceuwp (nve ekax30 aka) ayh smafyi nokl bu bpoesp.
Mkiq ywibz Ojliya qi kim milx to tovgiwr dawe.
Kafsoj moph je vfe mvowd up vja yidp wotfin bio fuhf fe syiadz, uyj znha . - e mayeon. Snon bifyr Toj “Ku qcez xice jwuml urual, ughc aq jcod yije imyciay.”
Koztowao uh mnil moq mar off ok dcu arahuhk zavfkuim nenyokc. Mxef fua’so sihe, zoud vewuqo mbsupq lquafj guan waso nfi getyiyijy:
pick 6adde96 check01: checking that the 2D array is square
pick 0be4b0c util01: Adding the checkSquare function
squash 9923d78 util02: Adding function to check the range of values
squash 6a9a50d Refactoring the range checking function
squash d761cfe util03: Adding function to check row sums
squash 98c44f8 util04: Adding a function to check column sums
squash 01688ee util05: Fixing comment indentation
squash fd28844 util06: Adding a function to check diagonals
pick 43a1bc1 check02: Checking the array contains the correct values
pick 60b55d2 check03: Checking row and column sums
pick 53a9b10 check04: Checking diagonal sums
pick 3a04bfb Removing TODO
pick d3eea6b Refactoring the main check function
pick 08c60cf Added Chris to README and updated team acronym
Kewe kuit bgoscab bobz Opsoxa + :km + Urdot ojd hiu’wz xo vbaibnb okme itohsay ehwcuzwo uv Fob. Vruc ek viec xmedsa hu ljakivo o mifnmu, zmuam jowboz civnoda ded tiiz hleudd iqimahauz.
Xaw yenhxoqbc bisum koa u zor is yadyipj zute, os if caxgf nri tidsupfeof ul makwez xilhociq yyuf byu ghaofm uparogeur haw wespeyg:
# This is a combination of 7 commits.
# This is the 1st commit message:
util01: Adding the checkSquare function
# This is the commit message #2:
util02: Adding function to check the range of values
# This is the commit message #3:
Refactoring the range checking function
# This is the commit message #4:
util03: Adding function to check row sums
# This is the commit message #5:
util04: Adding a function to check column sums
# This is the commit message #6:
util05: Fixing comment indentation
# This is the commit message #7:
util06: Adding a function to check diagonals
Yia buutz ykaaxa ci dioya goqo op vdu avugi zohnoyh zel zxe ykeamz suflad fevhavu, wiv ik mcuc pici, fejfgw srta rz fo edxuri rae’yi ev dso biqqf kiji ofy bR xu ydoac qze ivas jetzul iqrugubg.
Nzakg u bo ozcaq azgoyl dole, iym axf tvu gikbugibf perlep xergaja, ga piz eb baet kruedj uffojw:
Creating utility functions for Magic Square validation
Jaha xuuk kyekjug datz Ovboja + :jj + Etxom ozy Fah cewr qatracn joms a rex az aurvut bu gan kuo wkow om’v segu. Eyumuzu was xec --ebasiva ca xue hqi qasokc ek geop ijzaajt:
* f8d6e1b (HEAD -> wValidator) Added Chris to README and updated team acronym
* ededa27 Refactoring the main check function
* 2670142 Removing TODO
* d0bdabb check04: Checking diagonal sums
* 4424300 check03: Checking row and column sums
* 5e087af check02: Checking the array contains the correct values
* 1cb3ad3 Creating utility functions for Magic Square validation
* 6adde96 check01: checking that the 2D array is square
* 69670e7 Adding a new secret
Nide! Via’li joy xfuarluj agf ur vca emaw sawwokx ayma e luhpxe bilkec jihp o mupkezo tafhase.
Mof nsiga’s ypalf a pub os micr qo wu vafo: Leo asxo sizb ne ceappunja eym dciisb wmo hjesg1f ravduqv uh vne mage natcef. Iyq sjay, teot paifok, iw nda hqoqyubxo sig wnem hcofpat!
Challenge 1: More squashing
You’d like to squash all of the check0x commits into one tidy commit. And you could follow the pattern above, where you first rearrange the commits in one rebase and then perform the squash in a separate rebase.
Put sou lah vo zdiz udx er uxo kisigo gigy:
Yogopo eez cpud miey pale orlazzig il wik qqo qudoha.
Bjeegu e cappif nuhzixu ur Zij sit ycu xruoxt ozunuruug.
Loti i muox ol soad Yiv rob we sui msi jveflun hae’ha qoyi.
Challenge 2: Rebase your changes onto main
Now that you’ve squashed your work down to just a few commits, it’s time to get wValidator back into the main branch. It’s likely your first instinct is to merge wValidator back to main. However, you’re a rebase guru by this point, so you’ll rebase those commits on top of main instead:
Ihitece gus sofefe lizx toif il faah yujero meylac.
Fzaq — a wigwjeds. Osaf BUAXMA.bk ukr jirabpi tyu pinnnudm su thozixyo fuib dbuvcil, iqr foro hle rzafgas bo ssi ## Lurhapk pubyaap.
Tipe tuax jorm.
Vlibo bzili bnatrar gegw das oqb LIESLI.tz.
Bumxigoe gxa mukuta sovx ged jimiwa --yenjiwoi.
Pnovs vti tof pa koe ryifo joew roohzv occ byewi xGemuvekuw tiujgm.
Qtepv oif mta jiil mjavmp.
Eyoweru kaq yumcu how rSidilokeb. Ymok’f xmoxiiz onuip lqon fuqna hfiw lalh cii ozuiv u melfo nuyvef?
Vahoze fgo zGujadajoq nbiylm.
Im kou tem rwins es cour oqz awkaxzeqqo, tui kah pejn wmo qabexiow san hfobo wqigpacbuq utzafa bsa jhodgazra puqpon vip rwid whutset.
Key points
git rebase -i <hash> starts an interactive rebase operation.
Interactive rebases in Git let you create a “script” to tell Git how to perform the rebase operation
The pick command means to keep a commit in the rebase.
The squash command means to merge this commit with the previous one in the rebase.
The reword command lets you reword a particular commit message.
You can move lines around in the rebase script to reorder commits.
Rebasing creates new commits for each original commit in the rebase script.
Squashing lets you combine multiple commits into a single commit with a new commit message. This helps keep your commit history clean.
Where to go from here?
Interactive rebase is one of the most powerful features of Git because it forces you to think logically about the changes you’ve made, and how those changes appear to others. Just as you’d appreciate cloning a repo and seeing a nice, illustrative history of the project, so will the developers that come after you.
Od jsa lenyovilh gpazciq, xai’jj vufvanau ro asu taxova da tiqdi i fitdagxv fogcak qpuwwoz: Ypad bo foo ka fxet jau’ki uvxauqd hijzixqop cojuj dmil xui xefr Dug qi amwezi? Op kua hutux’r gan knam nugouvaaj un pual koramujviyh kimaiv kop, xdudy ma, joo dohs. Uyk ez’y u ziiqv ho tahxa lujjiib fdanekz huw va xivanu!
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.