Thursday, September 8, 2011

SVN Tutorial

svn can be known as subversion, it is a version control system after cvs. It claims to be out perform cvs, one of the features of svn is it do support versioning for documents and binaries beside source code.
As you search for subversion, it may lead you to the page of http://tortoisesvn.tigris.org/. Tortoise is a windows client of svn, you can even create svn repo using tortoise. Tortoise incorporate with windows explorer well, therefore it is easy to use.

When I migrate my svn repository to Linux, I couldn’t find any svn client that as easy as tortoise in windows. I was a bit upset at first. But not more for now, I have learn the way to cope with svn command line. I feel more control on it as in the sense that I know what am I doing by using command line compare to using GUI.
How to get help with svn?
If you are looking for svn reference in man pages, you have gone to the wrong place. To check the references of svn commands, simple do this:

svn help
This will make svn list all the available functions, to get the function reference, let say checkout

svn help checkout
The same thing goes to other svn related commands, such as svnadmin

svnadmin help
How to create a svn repository?
First of all what is repository? It is a core file for svn, or you can call it a centralized svn backup database. After created it, it is just a directory with its files. IMPORTANT! Do NOT try to modify or add something into the repository, unless you know what are you doing.
To create a svn repo, let say I wanna create a repo to store all my programming codes, I do this

svnadmin create /home/mysurface/repo/programming_repo
Remember try to use absolute path for everything, sometimes the relative path is not going to work.
How to import my existing directories into the new repo?
svn import /home/mysurface/programming file:///home/mysurface/repo/programming_repo -m "Initial import"
-m stand for log message, the first revision was created with log as “Initial import”. You need to specified URL for the repo, URL is the standard argument for svn. Therefore for local file, you need to specified with file://
How to see what is inside the repo?
svn list file:///home/mysurface/repo/programming_repo
Another way of listing all the files and folder in the tree view, I use svnlook
svnlook tree programming_repo 
The difference between svn list and svnlook tree is one expect URL another one do not.
svn command line tutorial for beginners 2 will covers how to checkout, track changes, commit, add or delete files and message logs.

No comments: