+ All Categories
Home > Documents > Version Control - University of the Pacific · Version Control Basics ì Big risk in putting the...

Version Control - University of the Pacific · Version Control Basics ì Big risk in putting the...

Date post: 05-Aug-2020
Category:
Upload: others
View: 0 times
Download: 0 times
Share this document with a friend
23
ì Computer Systems and Networks ECPE 170 – Jeff Shafer – University of the Pacific Version Control
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

ì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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Problem3–MultipleHeads

ì  Researchandanswerquestion3onyourown,andthenbeginthelab!

ComputerSystemsandNetworks

23

P3

Spring2020


Recommended