svn tutorial

Written by walter

STEP 1: Create a repository directory with svnadmin command (give full path here!):
svnadmin create /Users/wschrep/svn_repository


STEP 2: here we take a clean copy of the sources (or any directory with your project, again full path here).
And also give full path to repository and the dir in repository you want your project to reside in + a message with -m

svn import /Users/wschrep/cppWork/test/xmlparser file:///Users/wschrep/svn_repository/xmlparser -m "xmlparser import"

STEP 3: we do a checkout as follows:
svn co file:///Users/wschrep/svn_repository/xmlparser

STEP 4:
Now cd into this checkout and you can do svn commit, svn rm , svn add , etc.
If you want to fire up your favourite editor when doing add or commit's use following shell variable:
export SVN_EDITOR = joe
or
export EDITOR = joe

alternatively you can add a -m option. Example svn add bla.cpp -m "added bla"

Advanced:
Committing a project to a remote repository :

local mac we have xmlparser.
on remote nerdhero server we did

svnadmin create /home/walle/svn_repository

Now on my macbook i do this to put my sources on remote repository on nerdhero:
svn import /Users/wschrep/cppWork/test/xmlparser svn+ssh://walle@nerdhero.org/home/walle/svn_repository/xmlparser -m "xmlparser initial import"

This uploads the files to the remote repository (notice svn+ssh://walle@nerdhero.org instead of file:// )

Then checkout from remote to local is following:
svn checkout svn+ssh://walle@nerdhero.org/home/walle/svn_repository/xmlparser

SHARING REMOTE REPOSITORY:
We have a public svn in /var/svn where all users can access the files (otherwise you cannot share it).
Now we want to import from local macbook into nerdhero server at /var/svn/

this is wacko but works, on nerdhero i did
sudo svnadmin create /var/svn/xmlparser (because no write perms for walle in /var/svn)
Then on local machine i can already import it, but only after chmod'ing -R walle.walle in /var/svn/xmlparser dir (made by the svnadmin create).

Now the import
svn import /Users/wschrep/cppWork/test/xmlparser svn+ssh://walle@nerdhero.org/var/svn/xmlparser -m "xmlparser initial import"

Now the checkout:
svn checkout svn+ssh://walle@nerdhero.org/var/svn/xmlparser

Now we can add a file and commit it (but others can only read the repository, not modify it). We dont want to run the svn server deamon now so we work around it by chmodding the dir:
chmod -R 777 db

But this is not correct, now everyone on nerdhero can do a commit etc.

Correct way is using svnserver daemon which has permissions to write here (user independent and with seperate login/pass possibly).


Back to archive