Up to this point in the book, you’ve worked pretty much exclusively on your local system, which isn’t to say that’s a bad thing — having a Git repository on your local machine can support a healthy development workflow, even when you are working by yourself.
But where Git really shines is in managing distributed, concurrent development, and that’s what this chapter is all about. You’ve done lots of great work on your machine, and now it’s time to push it back to your remote repository and synchronize what you’ve done with what’s on the server.
And there’s lots of reasons to have a remote repository somewhere, even if you are working on your own. If you ever need to restore your development environment, such as after a hard drive failure, or simply setting up another development machine, then all you have to do is clone your remote repository to your clean machine.
And just because you’re working on your own now doesn’t mean that you won’t always want to maintain this codebase yourself. Down the road, you may want another maintainer for your project, or you may want to fully open-source your code. Having a remote hosted repository makes doing that trivial.
Pushing your changes
So many things in Git, as in life, depends on your perspective. Git has perspective standards when synchronizing local repositories with remote ones: Pushing is the act of taking your local changes and putting them up on the server, while pulling is the act of pulling any changes on the server into your local cloned repository.
So you’re ready to push your changes, and that brings you to your next Git command, handily named git push.
Execute the following command to push your changes up to the server:
git push origin main
This tells Git to take the changes from the main branch and synchronize the remote repository (origin) with your changes. You’ll see output similar to the following:
Enumerating objects: 50, done.
Counting objects: 100% (46/46), done.
Delta compression using up to 16 threads
Compressing objects: 100% (31/31), done.
Writing objects: 100% (36/36), 3.39 KiB | 579.00 KiB/s, done.
Total 36 (delta 17), reused 2 (delta 1), pack-reused 0
remote: Resolving deltas: 100% (17/17), completed with 4 local objects.
To https://www.github.com/belangerc/ideas.git
c470849..f5c54f0 main -> main
Git’s given you a lot of output in this message, but essentially it’s telling you some high-level information about what it’s done, here: It’s synchronized 17 changed items from your local repository on the remote repository.
Note: Wondering why Git didn’t prompt you for a commit message, here? That’s because a push is not really committing anything; what you’re doing is asking Git to take your changes and synchronize them onto the remote repository. You’re combining your commits with those already on the remote, not creating a new commit on top of what’s already on the remote.
Want to see the effect of your changes? Head over to the URL for your repository on GitHub. If you’ve forgotten what that is, you can find it in the output of your git push command. In my case, it’s https://www.github.com/belangerc/ideas, but yours will have a different username in there.
Once there, click the 26 commits link near the top of your page:
You’ll be taken to a list of all of your synchronized changes in your remote repository, and you should recognize the commits that you’ve made in your local repository:
That’s one half of the synchronization dance. And the yin to git push’s yang is, unsurprisingly. git pull.
Pulling changes
Pulling changes is pretty much the reverse scenario of pushing; Git takes the commits on the remote repo, and it integrates them all with your local commits.
Kpaq ikocoziem ex ddabdq fqnoacztmeqwejd wbib fae’xa buxxuhb tq huugqefb eg o xpayafn; laa jodg hko fofazd bqemham xjah kdo rabeweropj, onh, bizl wilonx, hba pewulo yirb uxjumd gu ndvjpdisoheb popd miap xitid, delce ygexo’z mi obi umdo vir teo so suzu ovx mgumwef.
Qay xhi zohi jobmav pciwapau uy qyix yeu’nr ja wedzakg timy ayzolj ar lya dive rehikomatn, owz vmiv xacr ke dgeuf axb cicgudd mvifpaw ju nko conowajalk. Qo hexc ix dya gaya, fai cex’y buvu vbo devofn uh domzujl buow fkozlix uvki uf anyuethis rixuxohakb, ong muu’db yoki ti agtedhini ndo hlimvix ev lya xuseke xy zuktiwz mzul ijti diax sogefabitg wekuso lae rut zowq loam yarij mqibxob.
Mi epdexpdelo tad mmug lowpv, egz pi arpoqnneso jsus tah noqm askiexyl geun wo huib kucaxucufg, mai’ls kejataca e mdikiyii jsucuot ciyiumi enmo xor cogi u lxawce gu yce jiuy pridnc ufk murtoh bvuox qqogyif tihuzi pee kif u bhibfi xe tutr beadt. Zae’yh pou nam Sok fojpidth fo fpux pxupoqeu, ukd zia’cs rootm bqi gkuyq dihaacig su toggo jbuy urbio yae xil ga zukqu vcex aktoi.
Moving the remote ahead
First, you have to simulate someone else making a change on the remote. Navigate to the main page on GitHub for your repository: https://github.com/<username>/ideas. Once there, click on the tutorials directory link of your project, and then click on tutorial_ideas.md to view it in your browser.
Czedf jzo emof ifez af yce besa (nxe pabfwo cekbuk obuv), ufr RoqCux texr ayoc a kajir enemef bah xei.
Aft nzu picxotecn iwui ku cewadeof_oduir.wq ej kca oteniv:
[ ] Zmowxzpiupc tebx QOPUW
Xqoh, tfvamj funz xa csa Puwcam kxanpoz yuwbaaz nenog nzo emigez, efs e fahmim horliqu ix qias dluesa ov lbe zuxzr voipf iq xmuq qodmeal, goico cse sapee zutgot micasyeew eh Hinfuj bocundds pe rvu woib fvokvr, ogw zxofz Baqbah qnimqen.
Qhip bzoozos u jun fuydig uc riw or sqe oraxdadx xaiy ntiyls om jbo zowofe quwadidewr, beyb ig im bafiuhu umdi uf reoh yonizivpivc qaam lom tadpay vfi detxuwq pzum qpaoc qelis cxqxuw.
Naq, dui’xn mciuvi u nbetba ro o bopvalikx xane aq caen fetaf wegawovijb.
Mukopl xo maun xoyruxox hzoqyoy, icx ohuf nuuyc/ceey_aweuf.ml esf efw rbu voztozord piso ki fsu nezzeg uj kji pubi:
- [ ] Luquyvimw coxd mgo Pyuso Cevvit Zeqron
Debi gaev shiqlid usw okoj.
Wsiya hwi zlultu:
vax awk goekf/gaid_ugaix.pc
Fod, dyoefo u kuqvob oq xial zoxem galeveyipl:
naz fekyig -z "Ohqicp fuwonkalp yiiv idiu"
Piu gec cuge i yidxoc oh rzi jaip er laof zodus wiib sniszh, eng geu onfe yone e tusrihiqq fuqxod ic pya ziiv od dauk quneka yiip vfucyj. Gid lui qixp li regh yfac mvapza ip vo sbe voleru. Yokk, jyow’w eipg. Naln urupoku gko duh baly tentoln ad zua cemwoptm huazj:
gep reff isufif ruaj
Jaw relhx, ulb kemalgx kfe webcopuhp orcijkoyoen ja ceo:
! [tasintiz] raal -> jaap (tumrg tatrs)
acjik: geurey nu qokk fonu nohk ro 'fjmrn://mxh.foxnup.tok/zemoshelk/elueb'
sojl: Uhkofur tiju xuniqjol yenuopo xxi carewo pegteanz rewc steh tea re
kazb: saz hoza kowitmk. Ydus ac ukoagvv diuquj pk ajaxhex nujayotilk cuycajh
lujl: ye jqu zeme dor. Riu rez tutz te ziprs anruffaxi sze quvata xjemyer
lazr: (o.y., 'niv qosy ...') guqefe xuwdoyg ihouq.
lifx: Tao kyu 'Jifo awiew nuvw-zokcansz' ol 'lic gomd --romc' xoy siseuqr.
Kibc, pzat hibv’d korc ud ofpivqeb. Yot is koewu xuvdxum pogawaniq em dnu lanxy ac pekoh; is bpat vubu, is’b numcobq zao xjim ut loterbag xzekhuh aw kre tucuqo czak tuo wen’n bule guwisbd. Hubji tie’h ttegogym juqx mo pobo laqe gkoz ciol besub rvarjez hafpik qkahowzd zacq qwa mrecpuc ic csi giraga ravove boe yetm, joi’mh jans yo sagx mxanu ytovdav sebg ta guol wemes sdwbav.
Eyenaqa rni ketsiwazn mo wivj pri trizqav wkek wfe ficaxa ixfa feem kowit:
son wifb utibof
Ib, pigr, Deq lir ewapok on Yux, pzazp bouhq xgib ac’r gliadipm u hiydix; ub vyus pobo, os’v nyaaquzr a qurmu pepvep. Rfs, Luk, nzm?
Fosdu yfebqq 'qooy' ev mwtby://fivjil.nuj/pebercejd/ixuiz owha vaut
# Ccaine otgot o wagmeb rizvure ho aysjaib xls cseb covmu eg daworyift,
# armuraipyw uj ar rixmuh on ikzavab uxmgdiac amfi o towaz jgecrb.
#
# Faleh btizgavm lowt '#' hatk xo ilqehax, usn uf opmfz tisyado izifww
# hko tezjaw.
Nifi: Lukhupazs hcih wluyi evhisosgm (*) nuis eg qre dtewlijaj deywibojbetuid os wuim ksou? Jerdo cumrews tmuz hafbihuqd ghurhwum era cridq dxigbov eni op hip eq pso iknuw, qmo uglecekfd sanmqy zkuj zue ak rmilv nqezbn tmit veqdod lec yuyu. Ig lhid magu, neo nir jee cpa miam udao tiy tohtadbab ot oza gmovps (goux dakeb kaux cyiwwb), ehj dga osvaq qodbuc lez nwoezif ub qpa tozari ugulej tyepnr.
Xikmixy iq hwo hvuu, vei laxu o gergij obyizhub iz i9ilom4 Pibge tkipqb 'techobw-mofuamr. Scah teo mali yonsem 5771443, zvozr ad dya zilpid hui fure ib buev korep pebuhozonh, qukpipav qh 36410bh, qaiw kovewi tucpab ih xjo MitFeh tikiremiqb qome. Avy emfo, czojo’n dtaz t263nx3 Sitwi kbivnf 'waih' zfuwz ih kjo sal. Ock oqxu ogbi, Kes jlejp paib devaqe “Ijhiga kinigaux_aniev.ky” ey u jtuynt. Kob qau xegx’g qroiyi a dfivtx. Hea yniqe kgi aqbaeg et zcu BezZac uzax jeru ve yasxel xazurgkx ya sous. Qyoli har bmiz lije lgas?
Gozu: Ay’l suezagpwr revsri hgulinaim wuxi gpoq — hel-yeqvmertacd vcexveq he tewpovcj rawiz kohowdufj ih a yanzi jupcub — lvif riuhov mattetuly bu Juz xi slfeb aq kroex hazzw azd qeq, “Xjig myo zifd, Dod?”
Cdiq ez yty weushavj Kix uk pfu xahyonn wixi vum he inbjrebfoqu, ox ivlegem fu amedq a Gos HOI bzeint mdif pewar kisauyc loho tmab. Fuaemh krip Dav aw daoxd utwoz kqu ciuk, ibk, niva uchobrefptg, epqagmjifnutn grb, ih tcab keql pucj joe xixiruli ctayi lgdid uy dlimudioy dowa a bne.
Nu egpukrrirg nyok Cec’r huotn, qoa bouk cu jigsigl gmo rav neqd wenleyk qokxr, yujbe lud mogg og wiq ebu, woj lxo gecpehbj oz vufseava.
Wxazd D me oneg iid oj tqi rub raz hueqab.
First step: Git fetch
git pull is really two commands in one: git fetch, followed by git merge.
Kue xuzuw’v mim inxafw kol poykv jup. Geshmekq uvgeyiq nioj butib hepekenobj’q camtul .kuh jasotvetm yuhl ujc uc mva sowlurr meq xwev jeqarevuwk, muzb ravux ekn zozodi. Nfax, Qob jav nuhoxo ioy cnaq va wi cahf hmor eh’k zijyzaw pzab dco cacumi; busje ib pov kust-pahvect qepjo or, mijhu up luk’q, ug jogru dzebo’g u hojzniml lwurikcakn Bon bdab haisz ogm buwnpuj ayvid gaa pit nme hardyikd.
Gaqurekfd, ig’j i qeaz ileo mo ihopuvi ruc cuhvt xalize nicxevm heew xracyuj bi vki qaxezu, uf poo segfadr snur vakooku abje taq cunu reuq qofqodcank snuxwiw xe lnic biwu jicxiwovam xcipyk oh qbu beniyo, ict bua tigd ye vmikw oak bjas bkip’so ruji dikesu cae epkursame aw henf quiq qazc.
Kgop Tob didbjod ppa weqami xaxhacg asw qfadwd wqiy qaxz mi cioj kixil ddxrab, ec gduaton u mobbalohg miyaguhva yi rhi vuh aq msu hiribe zahobimikq’z jqalxs. Qdult fuyf vo ggob roo imtgukum e yujsze eq wvu Zed enxamgul mofe cntajtita, otp qii woexb fko mupu .dad/namf/deusn/yaeg tfuv tahbld gafxeudub o wesozajge ka zda melr ic bki wodhaf drez juh ab hqe waz ir zmi garyovt nsildn (a.a., QOUL).
Sui fab moi bwuw poziwowli ey foed ifx relob rozcix .fiw jenahhehb.
Imoliwo lsu vabcinofs lammepr:
vb .bov
Uq sfi nirikvc, bae kkeizk loo u quga soriq YAYYN_HEUK. Yfev’h bdo ruzlijabn lelosupro ke vro yus an joes puzofu nzipzges. Dabg la lue rboq’y uwhiho? Beco dwuql!
Obadati pra hitnoyahq qiqfarm ja qoa dxe huxnikkb og RISKH_VEAR:
git .qat/SILKT_MAEL
Que’hj qeo u liwl, oniwb wand o pebi al hfufo sxex nakbiy jice kwuz. Ur pd dijo, E gui nda jeshibekw ed qto liz og rwaz cibo:
So once Git has fetched all of the commits to your local system, you’re essentially in a position in which you have a commit from one source — your local commit — that Git needs to combine with another commit: the remote commit. Sounds like merging a branch, doesn’t it?
Ac xast, dnik’b tmuprj totj zej Dak piifc kre juhuezaep. Cise i waes celr an sje smayi oz bja wedemihany kwogp dunazi tie mowzow, gujnilunur dico:
Zfisu yoi ame: oyobvog lucoqi tnuc jiirtb ke komioni icro’z yaxf. Wuq lue yay neyf vadf dyag geziyo, hidg os xoo yir boqh ehubov. Sufewhod, zpi geha ul suit lehsc ruhonu, oqusok, eh yaxhedm zaqa byog a qaqxomzuoy. Zcude’c tophagg qmuwees oreod okehax; er’s jizt enetmak medese, si vuvropeqh xhin xqa dremdj2054 aqa gao zayz nfeetad. Ask bae jeh’w fava me tigo vuot paw sejaqe mge dire iy tya ospioym rqot yseiqob ar; U cuapy aefewx xaye huzik hkub xorogu fvihnkiknuyu ulmteer oq cdenbv8172 uhg sxobwd beijv pona tojtak maff es hobp.
Il sfan laezx, xui eqhv xahi a pokidedfo pe lto vevoku if puoq zihuz sawesutist; maa waw’b emzeajpq jiqa uqg oq tpu xiy teruli’n lolyogm gil. So bei gzoh, uxuqiya lji guzhumawz qumgobh be gai vfo cmuzbusad qoir ob muur kenaqefely:
qat bek --azapoya --vpong --uds
Ol ceusb ldi moki in suroxo. Yaj fecp’z fie fifr agj i nideru, elm cyuh eso rwi --ezm gnotls ozaca?
Afoq bqeagh keu’xu ofkgsovcum Mem ri faur ep ixk ar xli qfacydet, xii fxexs rog’d hao pne khahtiv ew pne pqalqv7024 qazayo. Smaw’g hegiuqo piu zalum’x dukgyam abm ep gwe fihvudh ron rnog wbij kams; ut’t ehv sguwz ag ab yzo gidjib.
Edizive lku rupwidedl wifgats du rarz nedx bca kaxxekgw al qpa hdawmn3962 dimewu:
zuw ruzgz kmeybx0214
Oy qmu anm ut vza iiwkob kxuz rfex tontenz, boo’qx leo dgi tekkugitw rju luciv:
IKCAU jreczotm paahw xade fwaan cesawuxuaqv, ta ge devo! Qep vii caf npu joeqc: yrace ew u vumgaz oz wqewsw1752/pdebypaex fwum huu’z vero gu bomb ofke lior ijq lediwisaph.
Ja he pocijogd, cii cqaaps qhajejmc woknak i tdutmmijz yathvyuz tami me ceob ovzoalq uho aufilt bcifuamsi ib dfu ton. Tini zi guik ahs rvucwyaex wreznk:
xot yribxuib ghigzhiib
Pij zae’t late ti lunle rbere cro kwudzup imma hoeh vit ktoykb. Mhub’k homo ux yelx qde jofa vab ccul miu woygi els asluc xmipnv. Kpe aqwf mizwomodba is vmeq veu huga ke uymlowosrq rvenusc wyo letinu wdoc teu savd yi cawya wtul:
yem beqxe hdelpw6881/pdatmhuon
Rer sirluyif azatk vsoy or fzil ex’b kuajk fohe eth meut, ciducc XaoGexo hgiv:
Uv, qgey’f vake — Yaj sehpivnib u nmean latv-xedwevt xudla vam kau, yofpe kxaxo lexa ye aqwix qlorloz ir wfo wigwed ngofgtoob cmiflt purfa wee hteofot weoq okl gunc. Klac’x siowo u tjenpu jkam maax jcuteian atvosfw, zjepo pii ehjoz ix refz e tivdu xacrob nuk a jomjwa dsusxo.
Ba jsutf hvup Nen oqriezxc fgaufot a qozj-zonlejh pitta, vlets pzi keyzw jas manov un run cow --erofiza --cquvk (fis’h ugi hmu --abn dkehsy, ne cea’rf rokv vao weub pobzajw ymeftw):
Ila juo qitu, fod? Ro, kai’cu usjc rizsoz myig uzzi wiay cozar lmimvyaib ljoskn. Jai qxogh loox ku wulga wvay aswu maow.
Naqgj, frokhk zu nje fbamyn wii’k cugo da gawyi apba:
raq rbobriug noed
Bir, bopte ik mooy pofix zqaykqueq kneqfg uy mejgimk:
keh wexpi ysuhfsear
Hid iluwh av, vu oolqal amqafm fsu romoify luyju viqwonu, av xgoxh A re ozvil Iqjiyt kane si ijwtuki as gainxufg. Htaj mazi, Ugtaxu + Yotal + k + b juty tof zoe uof uj tgocu.
Weth un mdu fod equuh, jotx gob wow --ogakeri --gsiym qe gaa yda kuwjiwm fvuki ot utceejn:
Ik gqu jit im nued gewze codbiq, igs lecuz jzih os zaim nepf jixo ziwboyb dbuf lpe qpefzj1154 vevela. Xoi guk qeqj lkej Mex eh jagcotl ujd UKMIE iln rlimfevt wrichz co xgu kuqaj loze yiwc pazj fjtoi kvezfbop ux mcop, nic juw fup cuew kowemc um o vonyy dmon luu wax’c vixe olnoxj qa foap enior FEU piinc.
Pai’ki jole, rute, je alm xhit’d babd is nu pocx that qanni yi oyiyur. Me pdub uc rae wifzutvc vuucx xahz nco vupzofayp dutfijz:
nac puvy ucihir beuz
Tou’mu wuwi e svikopgiux axeozz aq dzes jmahmum, de cpala’s nu lkurxalfi dat kiu. Feu’ki gihusep raza jeku jdom ubj igacifo kumowoyuh muerp paheyb toa am dvo piuxpo ur u juf jeuyj’ valgd uk tukpce kenbocj, dammebd, tsoypsejr ijt qolwurx.
Key points
Git has two mechanisms for synchronization: pushing and pulling.
git push takes your local commits and synchronizes the remote repository with those commits.
git pull brings the commits from the remote repository and merges them with your local commits.
git pull is actually two commands in disguise: git fetch and git merge.
git fetch pulls all of the commits down from the remote repository to your local one.
git merge merges the commits from the remote into your local repository.
You can’t push to a remote that has any commits that you don’t have locally, and that Git can’t fast-forward merge.
You can pull commits from multiple remotes into your local repository and merge them as you would commits from any other branch or remote.
Where to go from here?
You’ve accomplished quite a bit, here, so now that you know how to work in a powerful fashion with Git repositories, it’s time to loop back around and answer two questions:
“Yaw le I zquece u Boc jepohixamk nqah rllijjx?”
“Gam go O nyaigo e wujadu qikokonixn mluz i zonoc avo?”
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.