A Guided Tour of Subversion (SVN)


the repository.

We will use the other method to import the actual project files, because these are already placed on correct location in our working place and also we want to selectively avoid the import of some files (e.g. compiled binaries). First we will checkout the empty SVN project folder into our actual project (to create working copy), then we will add the necessary files into the version control and finally we will commit them into the repository. The project files are located in folder [1] in the source zip file.

### Command Line

Non recursively checkout the trunk folder into the project root (don't miss the ‘.' in the checkout command)

cd hanoi

svn checkout -N localhost/repos/sandbox/Hanoi/trunk/ .

Now your project is a working copy (there is the .svn folder there). Recursively add src folder into the cource control

svn add src

Non recursively add all other files

svn add -N *.*

Ignore any content inside the bin folder

svn propset svn:ignore "*.*" bin

Commit all changes at once into the repository

svn commit -m "Adding the project content"

### Tortoise SVN

Right Click the "hanoi" folder -> Checkout... -> Enter the URL localhost/repos/sandbox/Hanoi/trunk; check "Only checkout the top folder" -> OK -> Yes (to checkout anyway)

Now your project is a working copy (there is the .svn folder there). Add the files into version control:

Right Click the "hanoi" folder -> TortoiseSVN -> Add... -> uncheck the *.class -> OK

So now all the files, extept the classes in the bin folder are scheduled for addition on commit. Next we tell SVN to forever ignore the content of bin folder:

Go to hanoi\bin\, Right Click Solver.class -> TortoiseSVN -> Add to Ignore List -> *.class

And finally commit all the changes:

Right Click the "hanoi" folder -> SVN Commit... -> Fill in the commit message -> OK


Now you can explore the repository content to see the project files inside and you can also check, that the project folder on your local disk is a Subversion working copy (each folder contains the .svn subfolder). When invoked from inside of working copy, both command line client and Tortoise recognize that and behave accordingly, e.g. they determine the repository location from the working copy.

As now the project is in the repository, multiple people can start working on it. We will simulate that by checking out another working copy, which will represent another user's workspace.

### Command Line

cd \Temp

mkdir bob\hanoi

svn checkout http:// localhost/repos/sandbox/Hanoi/trunk/ bob\hanoi

### Tortoise SVN

Create \Temp\bob\hanoi

Right Click the "hanoi" folder-> SVN Checkout... -> Enter the URL localhost/repos/sandbox/Hanoi/tru (it's probably already preset since the last operation) -> OK

Bob is now going to edit some files. He will add a new class Counter.java and modify the run.bat. You can find the final files in folder 2 of attached sources.

### Command Line

cd \temp\bob\hanoi

First, use svn status to see which files are new and modified, you will get:

?      src\Counter.java

M      run.bat

which indicates one new file (?) and one modified (M). Note, that the Counter.class in bin folder gets ignored. Now add Counter into the source control:

svn add src\Counter.java

(try svn status gain) and commit

svn commit -m "Adding the counter"

### Tortoise SVN

It's much easier here, since the commit window already does a lot of work for us:

Right Click the "Hanoi" folder-> SVN Commit... -> Enter the commit message and check the checkbox next to Counter.class -> OK


Now we will get back to the first user (Alice, of course), who imported the project. She updates her

About the author

AgileConnection is a TechWell community.

Through conferences, training, consulting, and online resources, TechWell helps you develop and deliver great software every day.