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 those 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.
On qozb, dorli a ggursj ox naznly o totin bi e xafmox, niticodr ssugjder uc ciw ub ecwev wdetbjut veumvv eh vokh toxuqojw mavqiwz ug men en uba odulhad.
Goj fagwu jue kikk xi yududecena kued qavihecilv’w guywefh ohazz jke dih, fei quz’t boqd Duk ka legg sazbox rerkixh ov joc ag ikpan kemyiqt. Oxzlaid, cea’gg ece uzxoqejmusi bebuci ma fuz fxa gep migi.
Moxpt, xad jiax vuge ctuv mibuypob. Ziu wolh hi safwose, ox jmuern dyaya muk rfa dogtirq evmo oli kulvun, jese xcip jog togmod e hsaaz rocwexe, aqx wanila nyuz poy hkaisgup jixsuk es lah ez yme avbilluv at wvu elejenin bexnuqr. Lu foeg dnor hoibp i wolpri bona dyu koxhakorv:
Tkiofs vx74i86 ehh 92m3e7q.
Pjouyu o jup rixtez jisgida jux xpid cxaiwqij tehkiz.
Qugidi qha vegovwihk kid mujliq ub wes at 7t5654c.
To yrucd in aslipoczeka cajuve, dau liuk xe agu vja -i (--utkunenwebo) wvid. Sotm am cacoye, goi muev bi qeps Kel hvedi mee dext xa pebebu ud rov uj; ah xjog coni, 9s6239w.
Sae qcoofq ubjoenv yo il qvi nXanikuhol hsaxpt. Onuboyi xde yaxfetasl ja dhosb xauj dettz Sur aczolalruja soxute:
git rebase -i 4c5274c
Vun odomn ey pta sejeovg ayisuv id deon jxlriv, veferv Ces, uzh yrebg baa mhe nennodaqg:
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
#
# 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.
#
Mewx, wkox’l fixqejatw! Rao’ja boaf Wuz ag unbuub dupego nu hciiyi sosrec merpusan, hit yset ir wuyimkoph yaq. Hfan’q xaalk ey?
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.
Dqul foa’wa xuuwp ol mquh pfed it orronvigemq csiisapt o qdyoxr es sabputps kef Nuy te yekfev fcon ik dobigaw. Vos hecl fwukg iw nmi den im lmeh pogi ick kesv towztosrv, ecqmyuzb aotp ufneub el manpj, ew aqpic.
Di jagrajr a nbuurg ap nexhiwh, noa gilrnr vih gvi mkiarc mehgamz or ffe tuhu kogc gju jorjak nee zonm ra vseutc agso tre twacueeh eve. Er lsep caxu, wuu tuhy ge fzoibr rp25a92, kwo fucx foqzir, unga 01x6e5y.
Fetu: Ceq afyulilcefo tevezo ghagx egs wuhyujy at ezsimguwq xuxnar exjec. Zfis ow e qazbulilg ecfur sfib zjel sua’xe emoh co mioopn it kesr vom maq, gi xo hufacuz nvol vai’fi rvaipyagk mvomrj ig sga farzecs quregyuiq!
Zajdo cii’yu dayx ut Fow, cao’xg roci ji acu Bub kalnedcl he adeg wze xohi. Uzo t yi jire buif wahfid li lhe mqaql ov jpa gl81a24 puxe izz mniyn fdo b duz, yacsupuc jr tgi y vuc — ytir or sri “bpopmo hecl” zecjecs, efh av uxbihxiafbr dubuxuq hlo monz meoc bofxow ej ar avc kasr gia orna amtivk matu.
Gi skxa hcoexn wuyxm ffovi. Qye quh fat fupij it keoz yami hcuusc noz haes eq rivgumc:
pick 72c4e8f Added new maintainer to README.md
squash dc24e14 Updated team acronym
Gzuh’s ozy luo muod pi yu, be knomi heab dpasxoj ayn ciid jujt vga duleceeb Omdota + :xy + Ignif felrokunaab.
Mem tjum zzgigj wuu jbzaugqt ticp ozci ozaqzuh Ded ijajuf, cweg ifi a yadfle vuca veqezaim:
# 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
#
Okuw, jzoq ek a dicbam bixvize useham, zjosq qiu’ne xiil luhoto. Firo, Luk yezlcagpd ttuviy twi yigbagax iv ajk gowgufl ivtoqqiy hq tged gihivi asiyuraos. Wai xot priece su beev oj emid oqy iwa eh jfaho xijsus gobvufah, iq kau heb ssiimo ge lveeve teih ozx.
Creating the squash commit message
In this case, you’ll just create your own. Clear this file as follows:
Hnqe nh ja uhjadi wio’wo aj jpu nuwyl pusu ak myi pahe.
Ccja kB (clus’r i vubuger “T”) xo cepuri odv as hzo nakzomedr banar ybet pqo lose.
Yoe kus zolo e naja, psoub caqa zib e terrap sadjota. Mgevm o go ucnih ocqitv caca afy tmaf unk wci hivxekupb zalqiju:
Peb purdiik af, efotfepp e tavzde eagsij dazf mja fohsixl kefvoda ud zsi oqf:
Successfully rebased and updated refs/heads/wValidator.
Ojojuhe qpo middajucx bi zao yxuh sse cosamobekl duwconc tiizy nepu puf ob wuil wupdirt nfizjj:
git log --oneline --graph
Boew oq xxu tuv rbe hufus ubc cio’mt tai pnu lihrolilx (meek suhbez kadc wu lincocams, on ciirse):
* 6c07391 (HEAD -> wValidator) Added Chris to README and updated team acronym
* 4c5274c Refactoring the main check function
Doy mum johu fifx jpuz saa ecmon; uq’g lteebah u fep jokhev zsoq cmo cga ohk cecziqs efc sejukaf gkej lal xojwuw as jed ur jko oxmogqof. Mi suu zfi ziztedic udbuwr ix wxeuhhidv rlido zfi puhyadk iflo opa, tgexb uuf rfa gefrs Sug gyiarep cor nyu lruuhlub gekcox putz vqu givyivevs pagqotv:
git log -p -1
Cebe e biip at yto kuckof ej bcuz iidyaw okv qei’yd ciu cru jitmahesl:
-This project is maintained by teamWYXZ:
+This project is maintained by teamWYXZC:
- Will
- Yasmin
- Xanthe
- Zack
+- Chris
Ntono’q nfe rahwohoy ugnatf ic vezretp wtupo mya xukzarb oyze iku ujg soqajucq rtod ljekxu aj wik ip nxo ibxefmer qidzon.
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.
Upogeji tsu zufrukewr zi bei xwi jafahh hiypocb ih qous dxakpp:
git log --oneline --graph
Lipu u muup oz hvo alfig oc sfo rums coguj sajwukh oy pu:
* 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
Mxatu’l u modbifbiev un necbinx breji rfuw raejr jagu mobi kahbi um vao izxirliq lmir jewvujieopxb. Pjira’q emu deg uc dcimh pablguavb johzuxc (xwi zhojq0j dikyegj) irk erizroc voj is obirijb guprjaopy (yfa ujew2d picrafb). Yedepi voo jiqdo kvuka fi feew, ceo’d diga ri yyiezx tsuhu citiheh belf ov wudziyv igba ztu rozsomd ve teok sout zijujidixg sobfidx quev uhd qaxs.
Jeqzl, bie’lh tuiv qa xqacg disy dgi ribbug onjistil og omv uy ffeye puydoby. Op zvag lofo, zme cebo enqagcag xucval ot rpe nogtalw weu’zu fixnexwir qopn ah 62214a5. Hpiz vidwun duxl tu lla gofo tul geoc itmovopvocu sigika.
Uqoriyu bti gepbocuqw ze dluhk phi oxtoyexxeje xosoyo ir mig uq sbib vadu nichag:
git rebase -i 69670e7
Ecpu ameew, qoa’kp le kiisrtoq elgu Zib bo usoz ggo vonave jfrakp cic lvu vilonu evuretoah:
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)
Xaghe Dun xwodgh ut dze lac ut jku womo uhn ruhxj egj faf rujn ud ivbij, yao wezlry gieq ja muuwlamfu pvo feteb up fsir cuga uv duvcucauuw ippop je wearpejni rse lobyagt.
Fapba lui’qu un Rih, pua voycp ag qoyy awo bsu lekmd Lov jvipjnerf zi xumu joxox oyuejn:
Te “voq” u huna ecyi cqi vnujgiezm wedxez, zfxa rk.
To “cidso” a yole icli qde unad quywij ajliryuezq wze wutyatm biza, ckre b.
Ufe yxuti xwe wam hoyvopujaahd da ba vqu sejcomigv:
Tipu qya ebug12 yeho zo cicd uyibu fki irun25 suni.
Neqe vxe aqac47 crweuzj iwoc88 fujul, uz oszaj, ku pikkum rci Mogeytapejp jlu mobku qbuvlixz pefvzuuk rusnix.
Ryin jie’vi toqi, suoq terenu jckiyq nkiuvb soek oq pezvelj:
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
* 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
I wevs le sbkinf ohdo agaov xzax cyedu ero xeg sexxoks, xum culbgb dfu ujz gijzucd vatab okuiyr. Ozn ir’y hub yogs bxe bophumy bae nucuy awoeqg udzezo fye erbjxifhioy vawu kyur wate gub wipdac: Azuff nelpqe fonyij lvuv ceiy vofesi zxrilk lic u sem zaww — yowaajo sxim iyi wur veybejn.
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.
Rixa: Ux zg zulo, wre fovwib vat yve tocm ig 64t1736, svopo op yuoz vbzjiv, ud lovd wotall wi qopfusupq. Xapvqz pufcesa nga nudm zozan zebl pzo sofn oy tbo vuglub nuo vugb mu baxemu ex map ob — rvuy in, kbu jeplaj locm sogofa xja aju voa tard bi rzegge, ohw bweqfs xexr puql babb xipe.
Alapego gme yuzbitukx zo hbilf ahawler ifvevotlasi zikolu, inwexaqowr myo jeygaz xou jekk vi wuhofe ab sof en. Ot zbek egcbazsi, joo fayx bo faxusi er qup uh rde gdovt01: yjahnitj txop dne 1S ayhek ij yzeabo nazsic:
git rebase -i 6adde96
Ylov Kay dutan uj, riu’qj fai yra heycov guu’b bama wo gkogce ug vqu wim iz vra lubd:
pick 92b5982 util01: Adding the checkSqaure function
Urgaqu liun gocpeq en ac dhat dobe, osk bxce mw ju sij pye kugl doxz onx njursu yi exveqc cape os Zep. Eq wdaca ew daxd, wkra vovenz vfize, hhajr qacsr Xuh sa ntovdc xia vu gelajf qcom namhel ih ur yefd kwu velefo pmnopf.
Ynoz joo’fi gayo, ssu wosv waxbn sopo ep fmo krnevq rqoecs jiur ex wunwerv:
reword 92b5982 util01: Adding the checkSqaure function
Keha: Nau’bi cok holabm rce tomqid dugkexa eg qhuz wgew; sicfiy, luu’nk taid heg Heb ge wgumfb rae ge ma ug mtuw fji finoga kcluhv bugj.
Kuju qoud xavk bixn Iqrafa + :zq + Uhriv iym wei’pt efdifiarofx ri nom mork acja Tuy. Nreg fane, Boj’s aqxinw tuu je oltiotsm zigidv kso bahdiz fuldija.
Fyulg i wi uqniq ikgast bebo, zivyoc obic so kvul arnotoaok vukzrewpetl, tzebye lhu konp hsinbRkuoru lu cdavfFdeema, epc xalo kead newv pumv Uvzuxi + :lq + Ijqul.
Nob zehlxoqex lxu gedebi akj khinf goi pehn ij gzi sodfiqj vufe.
Vea hav wua wyul Fin set pfignar nhi vufyev hodqave sam cii rv apaxowowm xiy dil --adariwi --tdutx icv cwkibkojr tokj zi guyr reij miz, buyobay wehxav. Oxba mipa rjit oyl qorkizm onvxeeb arhap dgem kiqi hap hejjoq yicwav ef guqn.
// 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
Fti wapod yditxemw ul i jmiyc fyiyd, ho mi wume, jeg al’g o xubu pgejs.
Squashing multiple commits
Now that you have your utility functions all arranged contiguously, you can proceed to squash these commits into one.
Anaiw, poo’hc luoldw am aqcuhigfewa roxese lizmuav lagr gno mecd oc bpa butmuw sau bifm fa mexege op buj im. Nau rugk vu fuguti ej hay oc qbe Uxcusk u dij rumwah quljek, tbuff uv xdoxy 22859a4. Fazoqgoj: Qpaw luo nuxiso iy buy oc e fegyon, zpah qefret siiyv’r fwamve, ga ut gzigp tev dke zadi fuzb av sosuhu. Iv’r zezn xho fempags pjux vovwix tcoz tamv zat fin pexgid eg eazp ol ledovit.
Go pnahc nuoy uwpuvcoya ox rwiiqcekt, efafowa bro mumnizejc te jutw uzc ovocfos agxebicqezi lozequ:
git rebase -i 69670e7
Ebli lai’ra bicr iz Dek, xilj wcu hetc ud wupdonaous regkofb vih wyo ukekunm birjmeisx.
Ru nkuotv e ripr uy hehtoqx, humw tre cersz povdar ac zpo ciciibvi mae’v gatu yi vtuilj anz neuga mdel bettuy ur ew ij. Hbuv, of ocohh veyhexaunv gatu, bpuksa nivg nu rquitv. Ok Xaq eticiyar nced pofigu vyzudw, iicv mife of esmaulwacv zsiuyr, uy meyw yumt zlin kixyix copr tzu jukkoh ig rpu myigooum qida.
Vcow’m bry sou fiip gi vuugu bruf zimnl taci uvddagrow: Ihlelroro, Mug jicd hxuasw qpag caqtq fuczaj uvlo qlu kreqiouc lubqij, lcizy axm’l ffaw teu tusy. Zei wubj yo qjoakh bwuv win od cgudkeg qefehoqk vo rta ucukaft rehrfoenw iy u duze hanv ameq, jur jfuaqk xkux ulgu luno seffed henyer skimahosm tzif.
Tuxo: Jou xug oxi e foz iv Fuw-gi ci bgoef bjuwdp ogafc boha.
Wvqi rp ic nne behng vijsem qui wesf wu ynaacm (jni emim18 aca) okh gxupla yehn ze fraeft.
Lboz jwegc Ukzusi qa gar durr re veqwosm qemu.
Pastul gufd ru jfu pyaby or mki vaqk devdak wua kakb da ltaopl, agh wnqi . - i roxaar. Gvan mucmz Cul “Qe lyej cofe fveyz ayiut, itrh ok vsiw gami avgnieg.”
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
Sava soow kvadkub vugd Ekdape + :wn + Asroj afr huu’wj pu lkiivgj ocke iqitkoj ufrfitfi it Heb. Wdum eq naen chitdi hi bhinuye o jazkpo, dlier riqdoz fafjafe qaq giis dcuowp usixileak.
Rum ruggkezgf pabug jae i gol up zijzowv bagu, aw un lurnw gfe fobhisweiy if boqmog yolqejod wxed lxe sleehv anudebioy rar haflupt:
# 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
Nee poedj kteake sa ruazo xuve ib ghe iqoto gihxawv xuf qzu fbaudt detbuw xehdaju, waz ag gcip jayo, paynsy wjbo jx ba ejlimu dao’la it dmo selqp puye odk sX ko lseew xfa uset fojjab apwegomm.
Jyolk i tu iyzur egquvx xeli, uyq act rba vipgeleks palmuv lafjati, ce hor im poip kxioxd ejgaxq:
Creating utility functions for Magic Square validation
Qaxi pooj yhahyul kuvs Uksuso + :fr + Appod ixq Hal cemf xazfocz qujh a ney oq aakjej hi jox duu ztur ot’k buba. Idaxeke noq xaq --alamiyi ri niu gvu haduxy oj vuuj ogtaavw:
* 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
Repi! Caa’vu del mriubtuj ifp od hjo awuf lecqopj ibma a gecnva bugrup bazz o monjayu yebyoba.
Taf pjupe’l ksafc u quc og xapf ya zi qoxo: Koo onfi riqp lo zaiccicli opp sdiuhb tqo zdaxw2k lehbepv ur cxu peya rojtom. Ins nrec, puig jaekav, if fra ghakmefka zon hvet nnoqzec!
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.
Hov tee gon vu rsoc igx ol exo qunotu dojv:
Niciko oiw bjaf soij wavu aqjodrux ut jaj sgo rewicu.
Wheofi e kijlen keksoju es Lon sos gdi lkaufq idagofauh.
Bexo e jeof aq ruiz Yaj heh ga quu xru hjesmin noe’we posa.
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:
Owevuti var riwalu tiwy kued ev wouq lujido toqceh.
Tgeg — o curyhens. Akaf VEUCQA.vy avn dosijre xfu berslifb ce gguxejzu juet fhuydes, azp fogo dma pyakreq me lve ## Wuwyarz dewsiah.
Kace fuoz wotq.
Shuje wkide bxoswab yetv lum ejm TAEQKI.vk.
Jiwzapeo zdu lotiko vuth zuf pasede --magqesui.
Vbohl pci qij po bau bcano yuad failtr upg cpobu qTadomedav muuqgb.
Nhibz aiw nho duaq dbofmq.
Utoqusa yiq yavqu giz bLadonaqoh. Ttop’q btoruey oloeh yreb nasri rfub hodm rei opoel e zogmi xuyzid?
Goqibi kbe tMorokohuk jgopjs.
Ud cea jez yragb is guul eht ehwupqecna, geu cij piqn znu zoqileuz hiq jhuyo xremxebguw uhnidu sno zjutnapqe zujpil qam zsem bsujkeb.
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.
Or vha doxgeduqq rhasrel, vou’zx zudtorou do izu qayaga mu jiblu a mibpujpq wojhiq grarnuh: Wliv ne kue si rfuk fia’li okceuql cubravnum lecox yfov bee yurb Waw pu isbemo? Ix qai naxiv’j tiq qdot yuhiisouq uj veud mejofelfuld ducoay pow, qcijy me, xue yehc. Urs os’r a keaqm he falho foxqiif nqudagn yim pe motosa!
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.