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,
Apps Django-0.95 GNUstep Collections Documents Linux Music confman Downloads LUG mysvn WorkSpace
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’
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
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
— 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’
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.
#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 ?! 😀
This work was created by Parthan.S.R. on 13th August, 2006. Parthan can be contacted at email@example.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.