Download - Sub Version Intro

Transcript
Page 1: Sub Version Intro

A day with Subversion (SVN)

Sebastian Heimann

Institut fur Geophysik, Arbeitsgruppe Seismologie

February 15, 2007

Page 2: Sub Version Intro

Outline

1. Concepts (by example)

2. Vocabulary

3. Benefits

4. Further reading

Page 3: Sub Version Intro

The initial work

Let’s assume we have just made a quick and dirty hack, which wenow want to put under version contol for further development:

> ls /my/hack

Page 4: Sub Version Intro

Create an empty repository

> svnadmin create --fs-type fsfs /my/repos

Repository

Page 5: Sub Version Intro

The initial import

> svn import /my/hack file:///my/repos/hack/trunk \-m ’Initial import’

Repository

1

Page 6: Sub Version Intro

Checkout a working copy of hack

> svn checkout file:///my/repos/hack/trunk /work/hack

Working copyRepository

1

Page 7: Sub Version Intro

Add a new feature to hack

> cd /work/hack ; vi hack

Working copyRepository

1

Page 8: Sub Version Intro

Commit your changes to the repository

> svn commit

Working copyRepository

1

2

Page 9: Sub Version Intro

More than one person can now work on hack

Fu’s working copy

Repository

1

2 Fara’s working copy

Page 10: Sub Version Intro

Both implement their improvements

Fu’s working copy

Repository

1

2 Fara’s working copy

Page 11: Sub Version Intro

Fu commits his changes to the repository

> svn commit

Fu’s working copy

Repository

1

2

3

Fara’s working copy

Page 12: Sub Version Intro

Fara commits her changes to the repository

Fu’s working copy

Repository

1

2

4

3

> svn commit

Fara’s working copy

Page 13: Sub Version Intro

To get each others changes

> svn update

Fu’s working copy

Repository

1

2

4

3

> svn update

Fara’s working copy

Page 14: Sub Version Intro

Fu and Fara can go back to any previous revision

> svn update -r 1

Fu’s working copy

Repository

1

2

4

3

> svn update -r 3

Fara’s working copy

Page 15: Sub Version Intro

Internally the repository will only store differences...

Repository

1

2

4

3

Page 16: Sub Version Intro

...but it pretends to make a new copy on every commit.

Repository

1

2

4

3

Page 17: Sub Version Intro

Sometimes it may be useful to branch the project...

> svn cp -r 2 file:///my/repos/hack/trunk \file:///my/repos/hack/branches/mad

Page 18: Sub Version Intro

...this creates a copy directly in the repository.

.../trunk

1

2

4

3

5

.../branches/mad

Page 19: Sub Version Intro

Check out a working copy of the branch

> svn checkout file:///my/repos/hack/branches/mad \/work/mad-hack

Page 20: Sub Version Intro

You can now safely experiment with mad-hack, whilemaintaining a stable version of hack in the trunk.

> cd /work/mad-hack

> # edit it

> svn commit1

2

4

3

5

6

Page 21: Sub Version Intro

Tagging: You can also use the branching mechanism tomark a specific revisions as somehow special.

> svn cp -r 2 file:///my/repos/hack/trunk \file:///my/repos/hack/tags/stable-v1

Page 22: Sub Version Intro

Tagged stable version 1 of hack

.../trunk

1

2

4

3

5

.../tags/stable-v1

Page 23: Sub Version Intro

Vocabulary

I repository

I revision

I working copy

I to check out

I to commit

I to update

Page 24: Sub Version Intro

Vocabulary

I to branch

I to merge

I to tag

Page 25: Sub Version Intro

Conventions

I hack/trunk

I hack/branches/mad

I hack/tags/stable-v1

Page 26: Sub Version Intro

Benefits

I Unlimited undo!

I Collaborate with others!

I Enforces structured development

I Makes you document what you are doing

I Automatic changelog!

I Helps you organize your mess in $HOME

Page 27: Sub Version Intro

Further reading

Tutorial

I http://artis.imag.fr/~Xavier.Decoret/resources/svn/

Documentation (A good intro is in Chapter 2)

I http://svnbook.red-bean.com/nightly/en/

Online help

> svn help

> svn [command] help