version control - university of the pacific · version control basics ì big risk in putting the...
TRANSCRIPT
![Page 1: Version Control - University of the Pacific · Version Control Basics ì Big risk in putting the executable in version control ì If you forget to compile before a commit, the executable](https://reader034.vdocuments.mx/reader034/viewer/2022050503/5f95043bf5ec2f6dc154c1ab/html5/thumbnails/1.jpg)
ìComputerSystemsandNetworksECPE170–JeffShafer–UniversityofthePacific
VersionControl
![Page 2: Version Control - University of the Pacific · Version Control Basics ì Big risk in putting the executable in version control ì If you forget to compile before a commit, the executable](https://reader034.vdocuments.mx/reader034/viewer/2022050503/5f95043bf5ec2f6dc154c1ab/html5/thumbnails/2.jpg)
LabSchedule
ì Todayì Lab2–VersionControl
ì NextWeekì IntrotoC(forC++programmers)ì Lab3–CProgramming/BuildTools
ì Deadlinesì Lab1Report–Jan25h,2020by5am
ì SubmitviaCanvasì Lab2Report–Jan28th,2020by5am
ì Submitviaversioncontrol
Spring2020ComputerSystemsandNetworks
2
![Page 3: Version Control - University of the Pacific · Version Control Basics ì Big risk in putting the executable in version control ì If you forget to compile before a commit, the executable](https://reader034.vdocuments.mx/reader034/viewer/2022050503/5f95043bf5ec2f6dc154c1ab/html5/thumbnails/3.jpg)
BeforeVersionControl
1. <Report.doc>
2. <Report.doc.bak>
3. <Report-1.doc>
4. Emailofftopartner…
5. <Report-2.doc>
6. Partnerrespondswithdoc(thatismissingthechangesyoujustmade)
7. <Report-2a.doc>
8. <Report-2a-WITH-REFERENCES.doc>
9. Emailofftopartner…Partnerrespondswithnewdoc<Report-3.doc>
10. <Report-3-FINAL.doc>
11. <Report-3-FINAL-OOPS-FIXED-TYPO-FINAL.doc>
ComputerSystemsandNetworks
3
Spring2020
![Page 4: Version Control - University of the Pacific · Version Control Basics ì Big risk in putting the executable in version control ì If you forget to compile before a commit, the executable](https://reader034.vdocuments.mx/reader034/viewer/2022050503/5f95043bf5ec2f6dc154c1ab/html5/thumbnails/4.jpg)
VersionControlFeatures
ì Projecthistorytracking
ì Concurrentfileediting(merges)
ì Non-linearprogramhistory(branches)
ì Namingschemeforprogramreleases(tags)
ComputerSystemsandNetworks
4
Spring2020
![Page 5: Version Control - University of the Pacific · Version Control Basics ì Big risk in putting the executable in version control ì If you forget to compile before a commit, the executable](https://reader034.vdocuments.mx/reader034/viewer/2022050503/5f95043bf5ec2f6dc154c1ab/html5/thumbnails/5.jpg)
MotivationforVersionControl
ì Whywouldasingleprogrammer(workingalone)useversioncontrol?ì Backupfilesì Roll-backtoearlier(working)versionì Seechangesmadebetweencurrent(broken)code
andearlier(working)codeì Maintainmultipleversionsofasingleproductì Experimentwithanewfeature
ì Tryariskychangeina“sandbox”ì Ifitworks,youcanmergeitintotheregularcode.
Ifitfails,youcanthrowitaway.
ComputerSystemsandNetworks
5
Spring2020
![Page 6: Version Control - University of the Pacific · Version Control Basics ì Big risk in putting the executable in version control ì If you forget to compile before a commit, the executable](https://reader034.vdocuments.mx/reader034/viewer/2022050503/5f95043bf5ec2f6dc154c1ab/html5/thumbnails/6.jpg)
MotivationforVersionControl
ì Whywouldasmallgroupofdevelopersuseversioncontrol?ì Allthereasonsasingleprogrammerwould,plus…ì Mergingdifferentchangesmadebydifferent
developersintothesamefileì Addanewfunctionatthebottom?Safeto
automaticallymergeinì Re-writeafunctionatthesametimeanother
developerisalsoeditingit?Versioncontrolwillcatchthisandaskyoutodecidewhicheditsshould“win”
ì Blame–whowrotethisbuggycode?!?
ComputerSystemsandNetworks
6
Spring2020
![Page 7: Version Control - University of the Pacific · Version Control Basics ì Big risk in putting the executable in version control ì If you forget to compile before a commit, the executable](https://reader034.vdocuments.mx/reader034/viewer/2022050503/5f95043bf5ec2f6dc154c1ab/html5/thumbnails/7.jpg)
MotivationforVersionControl
ì Whywouldalargegroupofdevelopersuseversioncontrol?
ì Differentquestion:CouldyoudeveloptheLinuxkernel,AdobePhotoshop,GoogleChrome,etc…using:ì Asingleshared“folderofcode”?ì Emailingcodesnippetsbetweendevelopers?ì Everyonesitsaroundandsharesonekeyboard?
ComputerSystemsandNetworks
7
Spring2020
![Page 8: Version Control - University of the Pacific · Version Control Basics ì Big risk in putting the executable in version control ì If you forget to compile before a commit, the executable](https://reader034.vdocuments.mx/reader034/viewer/2022050503/5f95043bf5ec2f6dc154c1ab/html5/thumbnails/8.jpg)
VersionControlBasics
ì WhatkindoffilesshouldIkeepinversioncontrol?ì Programsourcecode(obviously)ì VHDL/Verilogfiles(fromdigitaldesignclass)ì Matlabscriptsì HTMLfilesì Serverconfigurationfiles
ì ImagineyouworkatLivermoreNationalLabs,andyourjobistomanageLinuxclustercomputerswith100,000+machines(nodes)…
ì Anythingthatisplaintext!
ComputerSystemsandNetworks
8
Spring2020
![Page 9: Version Control - University of the Pacific · Version Control Basics ì Big risk in putting the executable in version control ì If you forget to compile before a commit, the executable](https://reader034.vdocuments.mx/reader034/viewer/2022050503/5f95043bf5ec2f6dc154c1ab/html5/thumbnails/9.jpg)
VersionControlBasics
ì WhatkindoffilesshouldInotkeepinversioncontrol?
ComputerSystemsandNetworks
9
https://www.youtube.com/watch?v=WJVBvvS57j0 Spring2020
![Page 10: Version Control - University of the Pacific · Version Control Basics ì Big risk in putting the executable in version control ì If you forget to compile before a commit, the executable](https://reader034.vdocuments.mx/reader034/viewer/2022050503/5f95043bf5ec2f6dc154c1ab/html5/thumbnails/10.jpg)
VersionControlBasics
ì WhatkindoffilesshouldInotkeepinversioncontrol?ì Thesearemorewhatyou’dcall“guidelines”thanactual
“rules”…ì Binarydata
ì Howdoyoumergetwodifferentbinaryfilestogether?Nogeneral-purposewaytodothis
ì Anythingauto-generatedbythecompilerì Objectfilesorexecutablefileì Wastesspaceonuselessjunkthatcanbere-created
automaticallyì Texteditortempfiles(e.g.main.c~)
ComputerSystemsandNetworks
10
Spring2020
![Page 11: Version Control - University of the Pacific · Version Control Basics ì Big risk in putting the executable in version control ì If you forget to compile before a commit, the executable](https://reader034.vdocuments.mx/reader034/viewer/2022050503/5f95043bf5ec2f6dc154c1ab/html5/thumbnails/11.jpg)
VersionControlBasics
ì Bigriskinputtingtheexecutableinversioncontrolì Ifyouforgettocompilebeforeacommit,the
executablemaynotbeinsyncwiththeattachedsourcecode!
ì Bigheadacheifyoueverrollbacktothisversion!
ì InECPE170,allourexecutablefilescanbeproducedinunder5secondswithonecommand.There’snoneedtoincludetheminyourrepository
ComputerSystemsandNetworks
11
Spring2020
![Page 12: Version Control - University of the Pacific · Version Control Basics ì Big risk in putting the executable in version control ì If you forget to compile before a commit, the executable](https://reader034.vdocuments.mx/reader034/viewer/2022050503/5f95043bf5ec2f6dc154c1ab/html5/thumbnails/12.jpg)
Problem1–Comparison
ì HowaretheseVersionControlSystemsdifferent?ì Gitì Mercurialì SVN
ComputerSystemsandNetworks
12
P1
Spring2020
![Page 13: Version Control - University of the Pacific · Version Control Basics ì Big risk in putting the executable in version control ì If you forget to compile before a commit, the executable](https://reader034.vdocuments.mx/reader034/viewer/2022050503/5f95043bf5ec2f6dc154c1ab/html5/thumbnails/13.jpg)
DistributedVersionControl
ì WhydotheycallGitadistributedversioncontrolsystem?ì Conventionalsystems(e.g.,Subversionor“svn”)
haveacentralizedserverholdthe“master”copyì Distributedversioncontrol–eachcopyisitsown
full-fledgedmaster!(Butyoucanstillpushchangesfromoneperson’scopytoanother)ì Allowsversioncontroltoworkofflineì Allowsversioncontroltoworkwithad-hocgroups
ComputerSystemsandNetworks
13
Spring2020
![Page 14: Version Control - University of the Pacific · Version Control Basics ì Big risk in putting the executable in version control ì If you forget to compile before a commit, the executable](https://reader034.vdocuments.mx/reader034/viewer/2022050503/5f95043bf5ec2f6dc154c1ab/html5/thumbnails/14.jpg)
Universe1:CentralizedVersionControl(SVN)
CentralizedRepository
svncommit
Ivan’sDir Lisa’sDir Kevin’sDir Dorothy’sDir
![Page 15: Version Control - University of the Pacific · Version Control Basics ì Big risk in putting the executable in version control ì If you forget to compile before a commit, the executable](https://reader034.vdocuments.mx/reader034/viewer/2022050503/5f95043bf5ec2f6dc154c1ab/html5/thumbnails/15.jpg)
Universe2:DistributedVersionControl(Git)CentralizedRepository
gitcommit
Ivan’sDir Lisa’sDir Kevin’sDir Dorothy’sDir
Ivan’sRepo Lisa’sRepo Kevin’sRepo Dorothy’sRepo
gitpush
gitpull
![Page 16: Version Control - University of the Pacific · Version Control Basics ì Big risk in putting the executable in version control ì If you forget to compile before a commit, the executable](https://reader034.vdocuments.mx/reader034/viewer/2022050503/5f95043bf5ec2f6dc154c1ab/html5/thumbnails/16.jpg)
GitCommandFlow(usually)
1. git clone <repositoryaddress>a. #getrepoonyourdesktop
2. git add <filenames>#alwaysspecifyafilenametoadda. #addnewfilesandmakechanges
3. git commit -m <meaningfulcommitmessage>a. #committoyourrepo.Alsouse–atocommitchangedfilesb. Makechangesandrepeat3
4. git push #All done? Let everyone see
![Page 17: Version Control - University of the Pacific · Version Control Basics ì Big risk in putting the executable in version control ì If you forget to compile before a commit, the executable](https://reader034.vdocuments.mx/reader034/viewer/2022050503/5f95043bf5ec2f6dc154c1ab/html5/thumbnails/17.jpg)
MercurialCommandFlow(Typical)1. hg clone <repositoryaddress>
a. #getrepoonyourdesktop
2. hg add <filenames>#alwaysspecifyafilenametoadda. #addnewfilesandmakechanges
3. hg commit -m <meaningfulcommitmessage>a. #committoyourrepob. Makechangesandrepeat3
4. hg revert –alla. #ifnothappywithchanges,reverttolastcommit(do4)b. Then make changes and go to 3
5. hg push #All done? Let everyone see
![Page 18: Version Control - University of the Pacific · Version Control Basics ì Big risk in putting the executable in version control ì If you forget to compile before a commit, the executable](https://reader034.vdocuments.mx/reader034/viewer/2022050503/5f95043bf5ec2f6dc154c1ab/html5/thumbnails/18.jpg)
Problem2–GitCheatSheet
ì GofindaGitcheatsheet(or2)forfuturereference
ComputerSystemsandNetworks
18
P2
Spring2020
![Page 19: Version Control - University of the Pacific · Version Control Basics ì Big risk in putting the executable in version control ì If you forget to compile before a commit, the executable](https://reader034.vdocuments.mx/reader034/viewer/2022050503/5f95043bf5ec2f6dc154c1ab/html5/thumbnails/19.jpg)
VersionControlinECPE170
ì Versioncontrolrequiredforthisclassì Usedtodistributeboilerplatecodeforlabsì Usedtoturninassignmentswhenfinished
ComputerSystemsandNetworks
19
Spring2020
![Page 20: Version Control - University of the Pacific · Version Control Basics ì Big risk in putting the executable in version control ì If you forget to compile before a commit, the executable](https://reader034.vdocuments.mx/reader034/viewer/2022050503/5f95043bf5ec2f6dc154c1ab/html5/thumbnails/20.jpg)
VersionControlinECPE170
ì Ifyouonlydoonecheck-inattheveryendofyourproject,you'vemissedthewholepointofversioncontrol,andturnedavaluabletoolintoanobstacletocompletingtheassignment
ì Check-incodeonaregularbasis!
ComputerSystemsandNetworks
20
Spring2020
![Page 21: Version Control - University of the Pacific · Version Control Basics ì Big risk in putting the executable in version control ì If you forget to compile before a commit, the executable](https://reader034.vdocuments.mx/reader034/viewer/2022050503/5f95043bf5ec2f6dc154c1ab/html5/thumbnails/21.jpg)
ComputerSystemsandNetworks
21
Spring2020
![Page 22: Version Control - University of the Pacific · Version Control Basics ì Big risk in putting the executable in version control ì If you forget to compile before a commit, the executable](https://reader034.vdocuments.mx/reader034/viewer/2022050503/5f95043bf5ec2f6dc154c1ab/html5/thumbnails/22.jpg)
ComputerSystemsandNetworks
22
http://xkcd.com/1597/
"Ifthatdoesn'tfixit,git.txtcontainsthephonenumberofafriendofminewhounderstandsgit.Justwaitthroughafewminutesof'It'sreallyprettysimple,justthinkofbranchesas...'andeventuallyyou'lllearnthecommandsthatwillfixeverything.”
Spring2020
![Page 23: Version Control - University of the Pacific · Version Control Basics ì Big risk in putting the executable in version control ì If you forget to compile before a commit, the executable](https://reader034.vdocuments.mx/reader034/viewer/2022050503/5f95043bf5ec2f6dc154c1ab/html5/thumbnails/23.jpg)
Problem3–MultipleHeads
ì Researchandanswerquestion3onyourown,andthenbeginthelab!
ComputerSystemsandNetworks
23
P3
Spring2020