WANdisco Free Subversion Training: Getting Started with SVN

Post on 07-Nov-2014

1.766 views 0 download

Tags:

description

WANdisco Free Subversion Training Webinar: Getting Started With Subversion Date: January 24 2013 Going back to basics! This course is intended as a primer for new users or people who are thinking of making the jump to Subversion. This will be a short introduction to the way Subversion works. All the topics that a new user needs to be exposed to. Topics covered: - Repository basics, creating and organizing - Checkouts, working folders, editing files and checkins - Reporting on changes - Simple branching - Simple merging

Transcript of WANdisco Free Subversion Training: Getting Started with SVN

Getting Started with Subversion

Presenter

Michael LesterWandisco

Director of Training

Getting Started with Subversion

3

Outline

Subversion Components Projects Layout Usual work cycle

Setup, checkout, commit demonstration

Branching Merging

Branching and merging demonstration

This training is done with the latest TortoiseSVN Version

http://www.wandisco.com/subversion/download

5

Repository SVN.EXE

WorkingCopy

WorkingCopy

TortoiseSVN

The central location of all versions of a project’s files.

Subversion Components

RepositoryA private work area created by checking out from Subversion

Working Copy

WorkingCopy

WorkingCopy

Repository

6

Subversion Organization

Repositories Projects

Folders

(subFolders)Files

7

Subversion Repositories

Repositories

• Can have a single or multiple repositories

• Can be on a server or local

• Can have access security

8

Subversion Projects

• Relates to a top level folder/directory

• Should have meaningful names

• Created (in repository) by the “IMPORT” or “COPY” command

Projects

9

Subversion Directories

• How projects are organized, just like folders

• Organized hierarchically• Created automatically via the

“IMPORT” command or “CREATE FOLDER” command

Folders

10

Subversion Files

• The end point

• All files must be in some directory

• Can exist in the repository and any number of working copies

Files

11

Repository Layout

Many options Main goal – minimize errors Other goals

Reusability

Ease of use Should be part of “Policies and Procedures”

Standardization easier on Admin tasks Too many objects per level can be confusing

12

Repository Layout - the TTB Layout

/ --- root mail trunk tags branches calculator trunk tags branches spreadsheet trunk tags branches

trunk – Main line development

tags – Snapshots in time

branches – Special / temporary projects

13

Repository Layout - Project Layout Example

calculator trunk tags rel 1.0 rel 1.1 rel 2.0

branches mike test_new_DB_access bugfix_rel 1.1 rel 2.1 cust_page_change QA rel 2.0 05_23_2010 rel 2.0 06_13_2010

14

Populating the Repository

This may be done by the users or admin

Two methods

IMPORT command

CREATE FOLDER (MKDIR) command

Repository

15

IMPORT Command

May require a log message

16

Create Folder (MKDIR) Command

May require a log message

17

WorkingCopy

WorkingCopy

Working Copy

.svn folder - Means this is a working copy folderThis is created and maintained by Subversion. You should never need to access this area, but you should NEVER delete it either.

The Usual Work Cycle

Check out

Edit

Update

Commit

18

Check Out

Check out

Edit

Update

Commit

This step gets the latest repository version of a project, directory or file and copies it to a location where it can be edited.

19

Check Out

Check out

Edit

Update

Commit

Two main parameters

Where from

Repository

Where to

CurrentDirectory

Relative Directory

QualifiedDirectory

20

Check Out

Check out

Edit

Update

Commit

Two decisions to make

Where from Where to

CurrentDirectory

Create a New

Directory

21

22

Creating a Working Copy

The checkout command creates a working copy folder.

23

Results of Checkout

Common Errors• Picking a level too high• Selecting an existing

working directory• Checking out before

doing a commit• Picking wrong

Repository or project

Icon Overlays

24

Indicates a fresh checked-out working copy of this file

Indicates a file has been modified since it was checked-out, and therefore needs commiting

Indicates a conflict while updating files

Indicates a svn:needs-lock property on the file. I.e. it is read-only.(You need to get a lock before you can edit this file)

Indicates a locked, but normal file. This symbol reminds you that you should unlock it for others to access it

Indicates that some files/folders inside a folder are scheduled for deletion, or a file under version control is missing in a folder

Indicates that a file or folder is scheduled to be added to version control

Same symbol for folder or file

Status - Check for Changes

Scenario•project1 checked out to c:\source\project1_mike•project1 checked out to c:\source\project1_sue•project1_mike jobs.txt changed•days.txt added•props.txt deleted•project1_mike committed

Are there any

changes?

25

Status - Check for Changes

Remember, to compare this project with the repository you need to select this option.

26

Update

Check out

Edit

Update

CommitDownloads all changes that have been made to files in the Subversion repository to your local copy.

Repositoryupdate Local

(working) copy

27

Possible Update Effects

Check out

Edit

Update

Commit

28

No conflicts

Possible Update Effects

Check out

Edit

Update

Commit

29

Conflicts

Possible Update Effects

30

Possible Update Effects

31

Comparing two versions

Diff doesn’t work on binary files

32

Add a Work File

Adding a file to a working directory does NOT add it to version control.

You need to use the SVN add command to let Subversion know it is part of version control.

After svn ADD

Before svn ADD

33

Delete Work File

Deleting a file in a working directory does NOTremove it from version control and the repository.

You need to use the svn DELETE command to let Subversion know it is no longer part of version control.

34

Delete File from Repository

Deleting a file from the repository does not remove it from the working directory.

It does remove it from version control.

35

Commit

Check out

Edit

Update

Commit

Committing is where you store a set of changes into the repository.

RepositorycommitLocal (working) copy

36

Commit

When you commit multiple files they all are tagged by the newly created version number.

Both files are marked at revision 19 .

37

38

Repository

Revisions

Projects

Directories

Files

The repository and everything in it go through revisions

1,2,3,4,….

39

Atomic Revisions

All changes, adds, modifications, and deletions, are part of the same revision (10).

40

Atomic Revisions

Selecting the revision will show all changes incorporated by that revision.

41

Branching, Merging and Conflicts

• Branches– What are they– Why we need them

• Merging– When to merge– When we never merge– How to merge

• Conflicts – Detecting conflicts– Resolving conflicts

42

What is a Branch

The basic concept of a branch:

A line of development that exists independently of another line

A branch always begins life as a copy of something, and moves on from there, generating its own history.

2nd branch

Original line of development

3rd branch

1st branch

43

Why we Need Branches

Branches are needed so that separate development efforts can take place at the same time.

Without branching we could never merge.

Branches make the development process easier and more understandable.

44

Creating Branches in Subversion

database

trunk

branches

Starting repository

Let’s assume that Tom wants to start working on the next release

45

Creating Branches in Subversion

Payroll

trunk

branches

Repository after the copy command

Tom can now check out the project starting at “tomNext” and know that any changes he makes will not effect anyone working on the “trunk” project”

tomNext

46

Merging in Subversion

Definition:Applying the differences between two sources to aworking copy path.

Example: svn merge file:///c:/svnrepos/projectOne -r346:348 foo.c

47

Merging Example

1 2 3

A development project is underway. A single file is represented. This file shows the list of offices in the company.

Since the beginning of this project we have made two changes.

Step 1.

offices.txt

48

Merging Example

Step 1. 3 4 5

Note: Revision 1 & 2 Created the trunk and branch folders

49

Rel 1.0

Step 2.

Merging Example

Create a new directory / branch named “Rel1.0”. Add this to the repository folder “Branch” After this, both the trunk and the new branch are changed independently.

For illustration, lets pretend thatIn the trunk a new office is added and in Rel1.0 a misspelling is corrected.

TRUNK

50

Merging Example

Step 2.

54TRUNK

Rel 1.0

51

Merging Example

A change is made to the latest version in the trunk directory.

A new office location is added.

Step 3.

TRUNK

Rel 1.0

52

Merging Example

The person responsible for “Rel 1.0” tells the person responsible for the “TRUNK” that they fixed a line of the file that should be propagated (MERGED) into the “TRUNK” .

Actually the merge happens into the workfile, then the workfile is committed back into the repository.

Step 4.

TRUNK

Rel 1.0

53

Merge Clarification

The merge DOESN’T EVER create a new version. A merge ALWAYS modifies a workfile.

The workfile can then be committed to the repository, which creates a new version.

The workfile created by the merge may be edited before the commit.

Step 4.

TRUNK

Rel 1.0

Workfile

Merge

We just show it like this for simplification

54

Merging Example

54

TRUNK

Rel 1.0

Step 4.

55

1. Practice on a temporary repository

2. Implement Subversion on real projects.

3. Get additional info, training, reading etc.

4. Create “Policies & Procedures”

5. Modify “Policies & Procedures” as you get more experienced.

Conclusions

56Copyright © 2011 WANdisco All rights reserved.

Presenter

Michael LesterWandisco

Director of Training

Feb 14thBranching Options for

Development

February 28th

Getting Info Out of

Subversion

What’s Next…

57

Save 30% on Enterprise SVN & Git Support

Our Support Engineers are the Sherpas of Source Control Management.

WANdisco support contracts include:

• Subversion Access Control

• Core SVN Developers & Git experts on

staff

• Guaranteed response times

• Indemnification coverage

Save 10% on SmartSVN Professional

SmartSVN is the world’s most popular SVN client for Linux, Mac and Windows.

SmartSVN Professional includes:

• Out of the box features

• A permanent license Key

• One year of free updates

• One year of free email support

www.smartsvn.com/buy

Use Discount Code: “SmartUpgrade10”

www.go/wandisco.com/getting-started-support-offer