+ All Categories
Home > Technology > Version control 101

Version control 101

Date post: 29-Jan-2015
Category:
Upload: michelangelo-van-dam
View: 107 times
Download: 0 times
Share this document with a friend
Description:
A basic understanding of version control with Subversion, how to choose your branch strategy and how to merge changes downwards.
Popular Tags:
37
Version Control 101 How to master SCM with Subversion
Transcript
Page 1: Version control 101

Version  Control  101

How  to  master  SCM  with  Subversion

Page 2: Version control 101

What  is  Version  Control?

• Maintain  versions  of  sources• Allows  for  collabora>on• Tracking  progress• Recording  history

2

Page 3: Version control 101

Why  Version  Control?

• To  work  on  something• Without  hindering  others• Try,  fail  and  start  over• Distribute  workload

3

Page 4: Version control 101

Lingo

• Repository:  the  loca>on  that  acts  as  Version  Control  system

• Trunk:  the  lifeline  of  the  project  where  everything  starts  and  everything  ends

• Branch:  a  custom  lifeline  for  individual  tasks  or  collec>ve  works

• Tag:  a  label  to  iden>fy  something  in  >me  (like  a  version  or  milestone)  

4

Page 5: Version control 101

• Branching:  the  act  of  crea>ng  a  side  lifeline  for  a  specific  purpose

• Tagging:  the  act  of  labeling  an  event  in  >me•Merging:  the  act  of  synchronizing  a  side  lifeline  with  his  parent  lifeline

• Integra6ng:  the  act  of  reuni>ng  the  side  lifeline  with  its  paren  lifeline

5

Page 6: Version control 101

Common  situa>on

1

2 3

4

5

6

7 8

9

10

12

13

11

Trunk

Tags

Branches Discontinued

6

Page 7: Version control 101

Trunk

• Is  the  most  up-­‐to-­‐date  lifeline• All  branches  start  from  here• All  branches  must  return  here

7

Page 8: Version control 101

Basic  merging  &  tagging

• Branch  from  TRUNK• Work  on  branch• Integrate  branch• Tag  event

8

Page 9: Version control 101

Standard  Layout

• Repository-­‐ trunk:  the  main  lifeline  of  sources

-­‐ branches:  your  playground

-­‐ tags:  your  memory  labels

9

Page 10: Version control 101

Trunk

Trunk

10

Page 11: Version control 101

Crea>ng  a  branch

Trunk

Branch

11

Page 12: Version control 101

How  to  branch

• svn  cp  ^/trunk  ^/branches/myBranch• svn  co  ^/branches/myBranch

12

Page 13: Version control 101

Keep  in  sync

Trunk

Branch

13

Page 14: Version control 101

How  to  sync

• svn  merge  ^/repo/trunk• svn  commit

14

Page 15: Version control 101

Integra>ng  a  branch

Trunk

Branch

15

Page 16: Version control 101

How  to  integrate

• svn  merge  -­‐-­‐reintegrate  ^/branches/myBranch

• svn  commit

16

Page 17: Version control 101

Tagging

Trunk

Branch

Tag

17

Page 18: Version control 101

How  to  tag

• svn  cp  ^/repo/trunk@12345  ^/tags/myTag

18

Page 19: Version control 101

Sub-­‐branching

• Why  sub-­‐branching?• New  branch• Small  sub-­‐branches• Integrate  back

19

Page 20: Version control 101

Why  sub-­‐branching?

• Working  on  a  large  task-­‐ With  several  dependent  sub-­‐tasks

• You  want  to  keep  related  sources  together-­‐ O^en  when  doing  versioning

• Try  stuff  out

20

Page 21: Version control 101

Create  a  sub-­‐branch

Trunk

Branch

Sub-branch

Same way as creating a branch!

21

Page 22: Version control 101

How  to  sub-­‐branch

• svn  cp  ^/repo/branches/myBranch^/repo/branches/mySubBranch

22

Page 23: Version control 101

Syncing  sub-­‐branches

Trunk

Branch

Sub-branch

23

Page 24: Version control 101

How  to  sync  sub  branches

• svn  merge  ^/repo/trunk  ^/repo/branches/myBranch

• svn  merge  ^/repo/branches/myBranch^/repo/branches/mySubBranches

24

Page 25: Version control 101

Reintegrate  sub-­‐branch

25

Trunk

Branch

Sub-branch

Page 26: Version control 101

How  to  reintegrate  sub-­‐branch

26

• svn  merge  -­‐-­‐reintegrate  ^/repo/branches/mySubBranch^/repo/branches/myBranch

Page 27: Version control 101

Reintegrate  =  End-­‐Of-­‐Life

27

Page 28: Version control 101

Complex  situa>ons

28

• A  project  with  mul>ple  tasks• A  project  with  mul>ple  developers

Page 29: Version control 101

Handle  complex  situa>ons

• Create  a  new  branch  for  the  project-­‐ This  will  be  your  own  trunk

-­‐ Keep  it  in  sync  with  TRUNK

• For  each  itera>on  create  a  sub-­‐branch-­‐ This  will  be  your  working  branch

-­‐ Keep  it  in  sync  with  project  branch

• For  each  task  create  a  sub-­‐branch  from  the  sub-­‐branch-­‐ This  will  be  your  feature  branch  (playground)

-­‐ Keep  it  in  sync  with  project  sub-­‐branch

29

Page 30: Version control 101

Visualiza>on  complex  situa>on

30

Trunk

Feature branch

Iteration branch Iteration branch

Task branches

XNew release

Merge

Merge

Merge

XHot fixes

Merge

Merge

Merge

Page 31: Version control 101

Remember

31

• Always  keep  in  sync  with  parent  branch• Merge  down  one  step  at  a  >me

Page 32: Version control 101

What  about  conflicts

• Conflicts  indicate  a  problem-­‐ Code  changed  on  same  posi>on

• What’s  “working”,  “le^”  and  “right”?-­‐ Working  is  the  current  situa>on  a^er  merge  with  your  code

-­‐ Base  or  le^  is  the  code  before  merge

-­‐ Head  or  right  is  incoming  changes  from  the  code  you  merge  with

32

Page 33: Version control 101

//File: example.php<<<<<<.working $this->property = $newValue;====== $this->property = $oldValue;>>>>>>.r12345-right

Example  conflict

• By  opening  the  conflicted  file-­‐ look  what’s  in  conflict

-­‐ discuss  with  developers  which  value  to  take

-­‐ if  both  changes  are  required,  you  need  add  both

33

Page 34: Version control 101

34

Don’t solve conflicts yourself!Always consult with all developers involved!

Changes made by one developer conflicting other developer’s changes might require both changes to be implemented!

Page 35: Version control 101

35

Some  advice

• Commit  smallEnsure  your  commit  contains  one  task

• Commit  o=enMore  commits  build  up  history,  allowing  to  replay  changes  you  made  easily  to  parent

• Integrate  quickDon’t  keep  sub-­‐branches  alive  too  long,  the  sooner  they  are  reintegrated,  the  easier  it  is  to  merge  with  other  tasks

Page 37: Version control 101

37

Contact  us

[email protected]

tel EU: +32 15 34 52 90tel US: (202) 559-7401

PHP Consulting

Training Courses

Quality Assurance

Web design


Recommended