Version control with CVS and Subvsersion

Being a software developer or making articles/reports/whatever using LaTeX it often requires to be able to version and backup your development. It also allows for cooperation between a number of people. CVS has been around for a long while and I have been using it since 2000. Subversion is a newer system which has tried to remedy some of the shortcommings of CVS. Personally I would recommend using subversion over cvs as it has better binary support for one thing.

Having a *nix account with either cvs or subversion and ssh access is a perfect start. For example here at DTU, where I work, I have an account on a SunOS system. It has both cvs and subversion installed as well as ssh-access. This makes the account accessible from a windows or any *nix system.

Setting up CVS in a linux/unix user home directory

This describes how to setup a cvs repository in a users home directory for his or her personal use on a unix/linux operating system.

Create the repository (SLOW WAY)

Step 1: Login to your account (either on a local or a remote account) or open a terminal window.
Step 2: Obtain the full path of of your home directory. Enter the command pwd immediately after login.

[martin@odin ~]$ pwd
/home/martin
[martin@odin ~]$

Okay, so my home directory is "/home/martin".
Step 3: Create the repository. I choose my repository to be located in "/home/martin/cvsroot".

[martin@odin ~]$ cvs -d /home/martin/cvsroot init
[martin@odin ~]$

Yes - we've created our own personal cvs repository. Let's make it the default repository each time login to this account.
Step 4: Make the repository the default repository for this account. Add the following line(s) to your profile (anywhere). For a bash account it's in ~/.bashrc.

export CVSROOT=/home/martin/cvsroot

Now either logout and login to initialise or run this command on your profile:

[martin@odin ~]$ source ~/.bashrc
[martin@odin ~]$

This should not give any errors! Test it by running the command:

[martin@odin ~]$ env|grep CVSROOT
/home/martin/cvsroot
[martin@odin ~]$ 

Good - the environment variable CVSROOT has been set!

Step 5: Create your own project and import it to the cvs repository

Create the repository (FAST WAY)

Type these commands and create your repository and entry in your bash-ressource file (~/.bashrc).

[martin@odin ~]$ cvs -d $HOME/cvsroot init
[martin@odin ~]$ echo "export CVSROOT=$HOME/cvsroot" >> ~/.bashrc
[martin@odin ~]$ source ~/.bashrc
[martin@odin ~]$ env|grep CVSROOT
CVSROOT=/home/martin/cvsroot
[martin@odin ~]$

CVS configuration file ~/.cvsrc

#
# always use compression level 3 when talking to a remote server. This
# is a life-saver when working over a slow connection.
# cvs -z3

## always use the -N (show added or removed files) and -u (unified diff
## format) options to diff(1).
diff -Nu

# always use the -P (prune empty directories) and -d (check out new
# directories) options when updating.
update -Pd
up -Pd

# always use the -P (prune empty directories) option when checking out.
checkout -P
co -P

Setting up the environment

1. One make a cvs repository in your home directory. It must be the full path
   specification. Login in to the server where you wish to create your cvs
   repository such as bohr.gbar.dtu.dk via ssh.
   Type the command "pwd" to get the full path of your home directory.
   Mine yields /kbar/lix0/home1/kt/v29924
   Now you must decide where you want to place your cvs repository.
   I want to mine in cvsroot (easyly memorized). Therefore I type:
      cvs -d /kbar/lix0/home1/kt/v29924/cvsroot init
   to create the repository.
2. In order to use the repository at first just locally I need to have
   a variable that tells where cvs should look for the repository.
   In file ~/.profile I have a line at the end saying:
      export CVSROOT=/kbar/lix0/home1/kt/v29924/cvsroot
3. Either logout and login again or issue a: source ~/.profile
4. Setup a new project, f.x.
     cd 
     mkdir mytestproj 
     echo 'testtext' > mytestproj/mytestfile.txt
     cd mytestproj
     cvs import -m "My initial project message" mytestproj beforecvs start
5. Now you project has been imported to cvs. Now here's the exiting part.
   Delete the project: rm -rf mytestproj
   Checkout the project from cvs: cvs co mytestproject
6. If your project is the being checked out from cvs, you then have successfully
   setup cvs in your home directory.
7. If you want to delete your testproject, just enter cvsroot
     cd ~/cvsroot
   and delete the testproject
     rm -rf mytestproj

*NIX specific:

When using cvs remotely via ssh the following must be setup (adjusted to your)
local profile settings in for example ~/.bashrc or likewise (according to your
preference of shell):

# CVS over ssh settings in local profile - change v29924 to your account name
# and the path to your home directory!
export CVSROOT=:ext:v29924@bohr.gbar.dtu.dk:/kbar/lix0/home1/kt/v29924/cvsroot
export CVS_RSH=ssh


For use with windows and turtoise cvs.
Add to .bashrc the following lines:
--------------------------------
export PATH=$PATH:/opt/sfw/bin
export CVSROOT=/kbar/lix0/home1/kt/v29924/cvsroot

For windows use:
o  The bash shell! (use ssh login and use command: "chsh bash")
o  Use Tortoise cvs tool.

that's it.
To use the project from a windows machine see:
   http://www.uni-c.dtu.dk/WinCVS.pdf
To use the project from another unix host see:
   xxx
To use it locally:
   see any cvs howto via google.

Subversion

Creating your subversion directory on your remote server with ssh-access:

$ svnadmin create svn+ssh:v29924@bohr.gbar.dtu.dk:/kbar/lix0/home1/kt/v29924/svnrepos
svn: 'svn+ssh://v29924@bohr.gbar.dtu.dk/kbar/lix0/home1/kt/v29924/svnrepos' is an URL when it should be a path
create: usage: svnadmin create REPOS_PATH

Ah okay. I need first to ssh into my account and then create the repository. Alright then. I can do that.

[martin@odin ~]$ ssh v29924@bohr.gbar.dtu.dk
bohr(v29924) $ svnadmin create /kbar/lix0/home1/kt/v29924/svnrepos
~
bohr(v29924) $ exit
[martin@odin ~]$ 

Okay we logged in to the server, and created the repository and then we logged out. Back at our own system we can initiate our project.

[martin@odin ~]$ mkdir /tmp/myproject /tmp/myproject/tags /tmp/myproject/branches /tmp/myproject/trunk

Good. Now move all relevant files to /tmp/myproject/trunk directory (including your project sub-diretories and files. When all your files are ready, we may import the project into subversion by the following command.

svn import /tmp/myproject svn+ssh://v29924@bohr.gbar.dtu.dk/kbar/lix0/home1/kt/v29924/svnrepos/myproject -m "Initial import"

Now we have our files in our repository. We can however not use the /tmp/myproject for further work, but we need to checkout the files from server and start working from that import instead. Checkout files from server and here we use the myproject/trunk to checkout files from and give it a proper name such as "theproject".

[martin@odin ~]$ svn checkout svn+ssh://v29924@bohr.gbar.dtu.dk/kbar/lix0/home1/kt/v29924/svnrepos/myproject/trunk theproject 

CVS

External links

Valid XHTML 1.0 Transitional