Dealing with Conflicting Updates in Git 0.6 Dealing wit… · Synchronizing with the server (1)...
Transcript of Dealing with Conflicting Updates in Git 0.6 Dealing wit… · Synchronizing with the server (1)...
![Page 1: Dealing with Conflicting Updates in Git 0.6 Dealing wit… · Synchronizing with the server (1) my-project docs manual.docx user_docs.docx src main.rkt module1.rkt module2.rkt module3.rkt.git](https://reader034.fdocuments.net/reader034/viewer/2022052016/602f62e192fa8a4c7666fe19/html5/thumbnails/1.jpg)
DealingwithConflictingUpdatesinGit
CS5010ProgramDesignParadigms“Bootcamp”Lesson0.6
©MitchellWand,2012-2014ThisworkislicensedunderaCreative Commons Attribution-NonCommercial 4.0 International License. 1
![Page 2: Dealing with Conflicting Updates in Git 0.6 Dealing wit… · Synchronizing with the server (1) my-project docs manual.docx user_docs.docx src main.rkt module1.rkt module2.rkt module3.rkt.git](https://reader034.fdocuments.net/reader034/viewer/2022052016/602f62e192fa8a4c7666fe19/html5/thumbnails/2.jpg)
LearningObjectives
• Attheendofthislessonyoushouldbeableto:– explainwhathappenswhenyoupullchangesfromanupstreamrepository
– understandwhataconflictis– resolveasimplemergeconflictinatextfile(includinga.rkt file)
2
![Page 3: Dealing with Conflicting Updates in Git 0.6 Dealing wit… · Synchronizing with the server (1) my-project docs manual.docx user_docs.docx src main.rkt module1.rkt module2.rkt module3.rkt.git](https://reader034.fdocuments.net/reader034/viewer/2022052016/602f62e192fa8a4c7666fe19/html5/thumbnails/3.jpg)
ACommit
my-project docs manual.docx
user_docs.docx
srcmain.rkt
module1.rkt
module2.rkt
module3.rkt
.git
commit
Whenyoudoa“commit”,yourecordallyourlocalchangesintothemini-fs.
Themini-fs is“append-only”.Nothing iseverover-writtenthere,soeverythingyouevercommitcanberecovered.
Rememberthebasicstoryfromthepreceding
lesson
3
![Page 4: Dealing with Conflicting Updates in Git 0.6 Dealing wit… · Synchronizing with the server (1) my-project docs manual.docx user_docs.docx src main.rkt module1.rkt module2.rkt module3.rkt.git](https://reader034.fdocuments.net/reader034/viewer/2022052016/602f62e192fa8a4c7666fe19/html5/thumbnails/4.jpg)
Synchronizingwiththeserver(1)
my-project docs manual.docx
user_docs.docx
srcmain.rkt
module1.rkt
module2.rkt
module3.rkt
.git push
Attheendofeachworksession,youneedtosaveyourchangesontheserver.Thisiscalleda“push”.
Nowallyourdataisbackedup.• Youcanretrieveit,onyourmachineor
someothermachine.• Wecanretrieveit(that’showwecollect
homework)
yourlocalmachine aserver,somewhereontheinternet,eg.github.com
4
![Page 5: Dealing with Conflicting Updates in Git 0.6 Dealing wit… · Synchronizing with the server (1) my-project docs manual.docx user_docs.docx src main.rkt module1.rkt module2.rkt module3.rkt.git](https://reader034.fdocuments.net/reader034/viewer/2022052016/602f62e192fa8a4c7666fe19/html5/thumbnails/5.jpg)
Synchronizingwiththeserver(2)
my-project docs manual.docx
user_docs.docx
srcmain.rkt
module1.rkt
module2.rkt
module3.rkt
.git pull
Toretrieveyourdatafromtheserver,youdoa“pull”.A“pull”takesthedatafromtheserverandputsitboth inyour localmini-fsandinyourordinary files.
Ifyourlocalfilehaschanged,git willmergethechangesifpossible.Ifitcan’tfigureouthowtothemerge,youwillgetanerrormessage.Dealingwiththisisbeyond thescopeofthistutorialL
yourlocalmachine aserver,somewhereontheinternet,eg.github.com
pull
5
![Page 6: Dealing with Conflicting Updates in Git 0.6 Dealing wit… · Synchronizing with the server (1) my-project docs manual.docx user_docs.docx src main.rkt module1.rkt module2.rkt module3.rkt.git](https://reader034.fdocuments.net/reader034/viewer/2022052016/602f62e192fa8a4c7666fe19/html5/thumbnails/6.jpg)
Q:Whenmightyouneedtomerge?
A:Whenyourpartnercommittedsomechangestotheserver,whichyoudon'thave.
Yourpartner'swork(onthe
server)
Yourwork(onyourlocalmachine)
Yourlastpull
6
![Page 7: Dealing with Conflicting Updates in Git 0.6 Dealing wit… · Synchronizing with the server (1) my-project docs manual.docx user_docs.docx src main.rkt module1.rkt module2.rkt module3.rkt.git](https://reader034.fdocuments.net/reader034/viewer/2022052016/602f62e192fa8a4c7666fe19/html5/thumbnails/7.jpg)
ResultofSyncing
Yourpartner'swork(onthe
server)
Yourwork(onyourlocalmachine)
Yourchangesareappliedtothelatestversionontheserver.Thisiscalled"rebasing"
Combinedworknowlivesonboththeserverandyourlocalmachine.
7
![Page 8: Dealing with Conflicting Updates in Git 0.6 Dealing wit… · Synchronizing with the server (1) my-project docs manual.docx user_docs.docx src main.rkt module1.rkt module2.rkt module3.rkt.git](https://reader034.fdocuments.net/reader034/viewer/2022052016/602f62e192fa8a4c7666fe19/html5/thumbnails/8.jpg)
Mostofthetime,thisworkswell
• Solongasyouandyourpartnerareworkingonseparatepartsofthefile,thisworksfine.
• Bothsetsofchangesgetmade,andthehistoryontheserverstayslinear
• Butwhathappensifyouandyourpartnercommitincompatiblechanges?
8
![Page 9: Dealing with Conflicting Updates in Git 0.6 Dealing wit… · Synchronizing with the server (1) my-project docs manual.docx user_docs.docx src main.rkt module1.rkt module2.rkt module3.rkt.git](https://reader034.fdocuments.net/reader034/viewer/2022052016/602f62e192fa8a4c7666fe19/html5/thumbnails/9.jpg)
Here'swhatyou'llsee
9
![Page 10: Dealing with Conflicting Updates in Git 0.6 Dealing wit… · Synchronizing with the server (1) my-project docs manual.docx user_docs.docx src main.rkt module1.rkt module2.rkt module3.rkt.git](https://reader034.fdocuments.net/reader034/viewer/2022052016/602f62e192fa8a4c7666fe19/html5/thumbnails/10.jpg)
So,clickontoolsandopenashell
Don'tpanic!First,lookatthefilein
aneditor
Here'swhatwe'regoing to
do
10
![Page 11: Dealing with Conflicting Updates in Git 0.6 Dealing wit… · Synchronizing with the server (1) my-project docs manual.docx user_docs.docx src main.rkt module1.rkt module2.rkt module3.rkt.git](https://reader034.fdocuments.net/reader034/viewer/2022052016/602f62e192fa8a4c7666fe19/html5/thumbnails/11.jpg)
Here'swhatthe
conflictedfilelookslike(inemacs)
what'sontheserver
what'sonthelocalmachine
11
![Page 12: Dealing with Conflicting Updates in Git 0.6 Dealing wit… · Synchronizing with the server (1) my-project docs manual.docx user_docs.docx src main.rkt module1.rkt module2.rkt module3.rkt.git](https://reader034.fdocuments.net/reader034/viewer/2022052016/602f62e192fa8a4c7666fe19/html5/thumbnails/12.jpg)
Next:editthefilethewayyouwantit
nomore>>>'s
12
![Page 13: Dealing with Conflicting Updates in Git 0.6 Dealing wit… · Synchronizing with the server (1) my-project docs manual.docx user_docs.docx src main.rkt module1.rkt module2.rkt module3.rkt.git](https://reader034.fdocuments.net/reader034/viewer/2022052016/602f62e192fa8a4c7666fe19/html5/thumbnails/13.jpg)
addthefixed-upfiletothecommit
tellgit tocontinue tothenextchange
ok!wearereadytosync
ifthereweremoreconflicts,we'dhavetodothisprocess
foreachofthem. 13
![Page 14: Dealing with Conflicting Updates in Git 0.6 Dealing wit… · Synchronizing with the server (1) my-project docs manual.docx user_docs.docx src main.rkt module1.rkt module2.rkt module3.rkt.git](https://reader034.fdocuments.net/reader034/viewer/2022052016/602f62e192fa8a4c7666fe19/html5/thumbnails/14.jpg)
Andwe'rereadytogetbacktowork
Observethatbothcommitsarenowin
yourhistory
14
![Page 15: Dealing with Conflicting Updates in Git 0.6 Dealing wit… · Synchronizing with the server (1) my-project docs manual.docx user_docs.docx src main.rkt module1.rkt module2.rkt module3.rkt.git](https://reader034.fdocuments.net/reader034/viewer/2022052016/602f62e192fa8a4c7666fe19/html5/thumbnails/15.jpg)
Isthisapain?• Yes,butitshouldn'thappentoooften.• Yourinteractionwiththeshellmightlooksomewhatdifferent.
• Buttheworkflowisthesame:– identifythefilesthatareconflicted– identifyandresolvetheconflictsineachfile
• theconflictedregionwillbemarkedwith>>>'s.• Useyourfavoritetexteditorforthis.
– Whenyougetthefilethewayyouwantit,addittoyourcommit.
– Commitallthefixed-upfiles.
15
![Page 16: Dealing with Conflicting Updates in Git 0.6 Dealing wit… · Synchronizing with the server (1) my-project docs manual.docx user_docs.docx src main.rkt module1.rkt module2.rkt module3.rkt.git](https://reader034.fdocuments.net/reader034/viewer/2022052016/602f62e192fa8a4c7666fe19/html5/thumbnails/16.jpg)
Summary
• Inthislessonyouhavelearned– whathappenswhenyoupullchangesfromanupstreamrepository
– whataconflictis– howtoresolveasimplemergeconflictinatextfile(includinga.rkt file)
16