Over a million developers have joined DZone.

Svn Cd.

DZone's Guide to

Svn Cd.

Free Resource
Shell Alias that allows you to cd into a svn repo, without checking out the entire repository. 
Since, each checkout or update is done non recursively, the entire repository is not checked out.   

function scd() {
    # Get SVN repo url and remove the parts we don't need.
    if svn ls `svn info |grep "URL: http://"|cut -c6-`/$1
        # Break apart each entry in the path 
        for partial in $(echo $1 | tr '/' ' ')
            # non recursively update that part and cd
            #  into the direcotry. 
            svn update -N $partial
            # Should check to see if the last entry is a 
            # file or directory before cd'ing into it.
            # Could do it like so:
            # if file $partial | grep -e ': directory$'
            # then
            #  cd $partial
            # fi
            # But I have not tried it out.
            cd $partial

The way one would use it is. First checkout you repo as normal except use a -N flag as well.
For example:
svn co -N http://www.example.com/repo/ /home/example/repo

Now say yoy wanted to go to your trunk, you would do:
cd /home/example/repo
scd some/long/path/to/a/set/of/modules/module1/trunk

You would now be in some/long/path/to/a/set/of/modules/module1/trunk everything but trunk checked out.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}