SVN, the first steps – A Mini HowTo for n00bs!

I had to deal with teaching a few Linux n00bs on how to start with SVN. Though my last post deals with using the SVN basically, it missed one big point which I perhaps myself learnt today – How to create a reposiroty and start with a working copy. I agree, I had difficulty over creating a repository though I very well know how to work on a working copy. This day, I had more things to learn and especially to find a list of things to be learned. Thus, I wrote a simple step-by-step howto for those who haven’t tried their hands on SVN before. As usual, I blog them too therefore someday when I myself couldn’t figure out how to do things, I can look at my own blog (Which I did today while dealing with MySQL).

Here goes my mini how-to for noobs on SVN….

Procedure to Create a Repository using SVN and basic operations with Subversion:

Step1. Create a repositry named mysvn in your home directory (assuming your shell’s current directory is your home, which is by default),

noob@dapper:~$ svnadmin create mysvn

Step1(b). Check whether your repository is created in the intended location,

noob@dapper:~$ ls
Apps Django-0.95 GNUstep Collections Documents Linux Music confman Downloads LUG mysvn WorkSpace
Desktop

Step2. Create a directory called code in your home, crate 3 sub-directories under it namely branches, logs and trunk. If you have some files to be placed, place it in the ‘trunk’ sub-directory.

noob@dapper:~$ mkdir ./code
noob@dapper:~$ mkdir ./code/branches
noob@dapper:~$ mkdir ./code/logs
noob@dapper:~$ mkdir ./code/trunk
noob@dapper:~$ ls ./code/
branches logs trunk

Step3. Now, import your newly created directory, named code to the repository using the SVN’s import command as follows,

noob@dapper:~$ svn import ./code file:///home/noob/mysvn/code -m ‘Initial Import’
Adding code/trunk
Adding code/trunk/testfile.txt
Adding code/logs
Adding code/branches

Committed revision 1.

Step3(b) This will add an invisible directory named code in the repos, though you cannot see them by getting into mysvn repos direcotry manually from FileManager or so. Don’t worry.

Step4. Checkout the newly created project in the repos, namely code, thereby cretaing a working copy in local filesystem. (may be in the same name or a slightly different name like mycode)

noob@dapper:~$ svn co file:///home/noob/mysvn/code code
A code/trunk
A code/trunk/testfile.txt
A code/logs
A code/branches
Checked out revision 1.

Step5. Now, change the content of any file in the local working copy under trunk and save the file. Now a file in your working copy is changed and lets have some fun with svn 🙂

Step6. Lets check the difference between the file in the repository and the local working copy, as we have made a change. The changes will the printed on the terminal, where a + denotes addition and – dentoes deletion or change.

noob@dapper:~$ cd code/
noob@dapper:~/code$ svn diff
Index: trunk/testfile.txt
===================================================================
— trunk/testfile.txt (revision 1)
+++ trunk/testfile.txt (working copy)
@@ -1,3 +1,6 @@
-This is a test text file. This file is intended to be moved to local
+8.20 PM: This is a test text file. This file is intended to be moved to local
repository (not working copy) named ‘mysvn’ under the project
‘code’. Hope everything works fine 🙂
+
+8.25 PM: Repository creation successful. Added files to repos and created a
+local working copy of the same name.

Step7. The change is found. Now as we have a modified working copy, we need to commit the changes so it gets updated int he repository as well.

noob@dapper:~/code$ svn commit -m ‘changed text contents’
Sending trunk/testfile.txt
Transmitting file data .
Committed revision 2.

Step8. Update your working copy so that you get the laest revision in your working directory.
noob@dapper:~/code$ svn update
At revision 2.

Note:
#1. This procedure is for creating a repository in your local machine, as well as the working copy in the same machine. This is a simple example of how to do the basic things. Read the SVN documentation available in the SVN’s official web site.

#2. Did you see, when we added the files from code folder using an import command, the revision changed to ‘revision 1’ from the initial ‘revision 0’ (sorry, how did i miss the output which showed revision 0 ?? 😦 ). And check again, when we did a ‘commit’ at step7, the revision again got updated to ‘revision 2’. Wow! It’s cool, isn’t it ?! 😀

*********************Licence*******************************************
This work was created by Parthan.S.R. on 13th August, 2006. Parthan can be contacted at parth.technofreak@gmail.com
This work is licensed under the Creative Commons Attribution License. To view a copy of this license, visit
tp://creativecommons.org/licenses/by/2.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.

Advertisements

15 thoughts on “SVN, the first steps – A Mini HowTo for n00bs!

  1. This is a great tutorial. It would be significantly better if you improved the names of your variables. JayaLDD is an awkward variable. If you changed it to something like code and changed the name of jayaldd to codeSVN or codeREPO. It would make it easier to read. Otherwise this was a great text!

  2. Stuart,
    Thanks for the comment. The blog post was actually a copy paste from a workshop I did in a college and hence contains names relevant to the college. Will change them as suggested 🙂

  3. ### noob@dapper:~$ mkdir ./code
    ### noob@dapper:~$ mkdir ./code/branches
    ### noob@dapper:~$ mkdir ./code/logs
    ### noob@dapper:~$ mkdir ./code/trunk

    can be done with:
    mkdir -p code{/branches,/log,/trunk}

    😛

    • Thanks for posting random stuff like this… Just added another two tools in my terminal belt:
      -p for mkdir
      &
      blah{asdf,fdas,jklsdf}

  4. Thank You! After fighting through lots of other tutorials, this is the first tutorial I’ve come across that has helped me to successfully set up a subversion repository.

  5. Thanks for the tutorial, it was very helpful.
    But I must add that I had to add the files to SVN before checking them out
    (“svn add code/*” after “svn import ./code file:///home/noob/mysvn/code -m ‘Initial Import’”).
    After that, all worked fine.

    a.

  6. Thanks for the nice writeup! It was a good refresher. I am trying to get my chop back with svn. (yeah I meant that singular – I never had more than one chop with svn)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s