version control 101
DESCRIPTION
A basic understanding of version control with Subversion, how to choose your branch strategy and how to merge changes downwards.TRANSCRIPT
![Page 1: Version control 101](https://reader034.vdocuments.site/reader034/viewer/2022051515/54c93deb4a79598c6c8b474e/html5/thumbnails/1.jpg)
Version Control 101
How to master SCM with Subversion
![Page 2: Version control 101](https://reader034.vdocuments.site/reader034/viewer/2022051515/54c93deb4a79598c6c8b474e/html5/thumbnails/2.jpg)
What is Version Control?
• Maintain versions of sources• Allows for collabora>on• Tracking progress• Recording history
2
![Page 3: Version control 101](https://reader034.vdocuments.site/reader034/viewer/2022051515/54c93deb4a79598c6c8b474e/html5/thumbnails/3.jpg)
Why Version Control?
• To work on something• Without hindering others• Try, fail and start over• Distribute workload
3
![Page 4: Version control 101](https://reader034.vdocuments.site/reader034/viewer/2022051515/54c93deb4a79598c6c8b474e/html5/thumbnails/4.jpg)
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](https://reader034.vdocuments.site/reader034/viewer/2022051515/54c93deb4a79598c6c8b474e/html5/thumbnails/5.jpg)
• 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](https://reader034.vdocuments.site/reader034/viewer/2022051515/54c93deb4a79598c6c8b474e/html5/thumbnails/6.jpg)
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](https://reader034.vdocuments.site/reader034/viewer/2022051515/54c93deb4a79598c6c8b474e/html5/thumbnails/7.jpg)
Trunk
• Is the most up-‐to-‐date lifeline• All branches start from here• All branches must return here
7
![Page 8: Version control 101](https://reader034.vdocuments.site/reader034/viewer/2022051515/54c93deb4a79598c6c8b474e/html5/thumbnails/8.jpg)
Basic merging & tagging
• Branch from TRUNK• Work on branch• Integrate branch• Tag event
8
![Page 9: Version control 101](https://reader034.vdocuments.site/reader034/viewer/2022051515/54c93deb4a79598c6c8b474e/html5/thumbnails/9.jpg)
Standard Layout
• Repository-‐ trunk: the main lifeline of sources
-‐ branches: your playground
-‐ tags: your memory labels
9
![Page 10: Version control 101](https://reader034.vdocuments.site/reader034/viewer/2022051515/54c93deb4a79598c6c8b474e/html5/thumbnails/10.jpg)
Trunk
Trunk
10
![Page 11: Version control 101](https://reader034.vdocuments.site/reader034/viewer/2022051515/54c93deb4a79598c6c8b474e/html5/thumbnails/11.jpg)
Crea>ng a branch
Trunk
Branch
11
![Page 12: Version control 101](https://reader034.vdocuments.site/reader034/viewer/2022051515/54c93deb4a79598c6c8b474e/html5/thumbnails/12.jpg)
How to branch
• svn cp ^/trunk ^/branches/myBranch• svn co ^/branches/myBranch
12
![Page 13: Version control 101](https://reader034.vdocuments.site/reader034/viewer/2022051515/54c93deb4a79598c6c8b474e/html5/thumbnails/13.jpg)
Keep in sync
Trunk
Branch
13
![Page 14: Version control 101](https://reader034.vdocuments.site/reader034/viewer/2022051515/54c93deb4a79598c6c8b474e/html5/thumbnails/14.jpg)
How to sync
• svn merge ^/repo/trunk• svn commit
14
![Page 15: Version control 101](https://reader034.vdocuments.site/reader034/viewer/2022051515/54c93deb4a79598c6c8b474e/html5/thumbnails/15.jpg)
Integra>ng a branch
Trunk
Branch
15
![Page 16: Version control 101](https://reader034.vdocuments.site/reader034/viewer/2022051515/54c93deb4a79598c6c8b474e/html5/thumbnails/16.jpg)
How to integrate
• svn merge -‐-‐reintegrate ^/branches/myBranch
• svn commit
16
![Page 17: Version control 101](https://reader034.vdocuments.site/reader034/viewer/2022051515/54c93deb4a79598c6c8b474e/html5/thumbnails/17.jpg)
Tagging
Trunk
Branch
Tag
17
![Page 18: Version control 101](https://reader034.vdocuments.site/reader034/viewer/2022051515/54c93deb4a79598c6c8b474e/html5/thumbnails/18.jpg)
How to tag
• svn cp ^/repo/trunk@12345 ^/tags/myTag
18
![Page 19: Version control 101](https://reader034.vdocuments.site/reader034/viewer/2022051515/54c93deb4a79598c6c8b474e/html5/thumbnails/19.jpg)
Sub-‐branching
• Why sub-‐branching?• New branch• Small sub-‐branches• Integrate back
19
![Page 20: Version control 101](https://reader034.vdocuments.site/reader034/viewer/2022051515/54c93deb4a79598c6c8b474e/html5/thumbnails/20.jpg)
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](https://reader034.vdocuments.site/reader034/viewer/2022051515/54c93deb4a79598c6c8b474e/html5/thumbnails/21.jpg)
Create a sub-‐branch
Trunk
Branch
Sub-branch
Same way as creating a branch!
21
![Page 22: Version control 101](https://reader034.vdocuments.site/reader034/viewer/2022051515/54c93deb4a79598c6c8b474e/html5/thumbnails/22.jpg)
How to sub-‐branch
• svn cp ^/repo/branches/myBranch^/repo/branches/mySubBranch
22
![Page 23: Version control 101](https://reader034.vdocuments.site/reader034/viewer/2022051515/54c93deb4a79598c6c8b474e/html5/thumbnails/23.jpg)
Syncing sub-‐branches
Trunk
Branch
Sub-branch
23
![Page 24: Version control 101](https://reader034.vdocuments.site/reader034/viewer/2022051515/54c93deb4a79598c6c8b474e/html5/thumbnails/24.jpg)
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](https://reader034.vdocuments.site/reader034/viewer/2022051515/54c93deb4a79598c6c8b474e/html5/thumbnails/25.jpg)
Reintegrate sub-‐branch
25
Trunk
Branch
Sub-branch
![Page 26: Version control 101](https://reader034.vdocuments.site/reader034/viewer/2022051515/54c93deb4a79598c6c8b474e/html5/thumbnails/26.jpg)
How to reintegrate sub-‐branch
26
• svn merge -‐-‐reintegrate ^/repo/branches/mySubBranch^/repo/branches/myBranch
![Page 27: Version control 101](https://reader034.vdocuments.site/reader034/viewer/2022051515/54c93deb4a79598c6c8b474e/html5/thumbnails/27.jpg)
Reintegrate = End-‐Of-‐Life
27
![Page 28: Version control 101](https://reader034.vdocuments.site/reader034/viewer/2022051515/54c93deb4a79598c6c8b474e/html5/thumbnails/28.jpg)
Complex situa>ons
28
• A project with mul>ple tasks• A project with mul>ple developers
![Page 29: Version control 101](https://reader034.vdocuments.site/reader034/viewer/2022051515/54c93deb4a79598c6c8b474e/html5/thumbnails/29.jpg)
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](https://reader034.vdocuments.site/reader034/viewer/2022051515/54c93deb4a79598c6c8b474e/html5/thumbnails/30.jpg)
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](https://reader034.vdocuments.site/reader034/viewer/2022051515/54c93deb4a79598c6c8b474e/html5/thumbnails/31.jpg)
Remember
31
• Always keep in sync with parent branch• Merge down one step at a >me
![Page 32: Version control 101](https://reader034.vdocuments.site/reader034/viewer/2022051515/54c93deb4a79598c6c8b474e/html5/thumbnails/32.jpg)
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](https://reader034.vdocuments.site/reader034/viewer/2022051515/54c93deb4a79598c6c8b474e/html5/thumbnails/33.jpg)
//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](https://reader034.vdocuments.site/reader034/viewer/2022051515/54c93deb4a79598c6c8b474e/html5/thumbnails/34.jpg)
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](https://reader034.vdocuments.site/reader034/viewer/2022051515/54c93deb4a79598c6c8b474e/html5/thumbnails/35.jpg)
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 36: Version control 101](https://reader034.vdocuments.site/reader034/viewer/2022051515/54c93deb4a79598c6c8b474e/html5/thumbnails/36.jpg)
Recommended Reading
36
Click on the books to order
![Page 37: Version control 101](https://reader034.vdocuments.site/reader034/viewer/2022051515/54c93deb4a79598c6c8b474e/html5/thumbnails/37.jpg)
37
Contact us
tel EU: +32 15 34 52 90tel US: (202) 559-7401
PHP Consulting
Training Courses
Quality Assurance
Web design