Table of Contents

The following steps/example indicate how to make SVN ignore files that does not have to be version controlled

Do the basics of repository creation and usage

Feel free to skip this section if you want to try this out in your production repository :-)

Move to temp directory - this is where we will do our POC

root@ub1:~# cd /tmp

Create a directory and few subs under which we can show this example

root@ub1:/tmp# mkdir svntest
root@ub1:/tmp# cd svntest
root@ub1:/tmp/svntest# mkdir -p a/a/a
root@ub1:/tmp/svntest# cd a/a/a

Create repository in a directory far away

root@ub1:/tmp/svntest/a/a/a# svnadmin create rep01
root@ub1:/tmp/svntest/a/a/a# ls
rep01
root@ub1:/tmp/svntest/a/a/a# cd /tmp/svntest

Create a directory for working directory

root@ub1:/tmp/svntest# mkdir wd
root@ub1:/tmp/svntest# cd wd

Check out files into the working dir

root@ub1:/tmp/svntest/wd# svn checkout file:///tmp/svntest/a/a/a/rep01
Checked out revision 0.

Show current SVN status (as empty) in the new working dir of new repository

root@ub1:/tmp/svntest/wd# cd rep01
root@ub1:/tmp/svntest/wd/rep01# svn status
<null output>

Create a data dir a1

root@ub1:/tmp/svntest/wd/rep01# mkdir a1

Add to VCS

root@ub1:/tmp/svntest/wd/rep01# svn add * --force
A         a1

Commit it.

root@ub1:/tmp/svntest/wd/rep01# svn commit -m "test"
Adding         a1
Committed revision 1.

Display data dir

root@ub1:/tmp/svntest/wd/rep01# ls
a1

Now, let's create some files we like to ignore

Create another directory

root@ub1:/tmp/svntest/wd/rep01# mkdir a2

Try to make SVN ignore this and its contents

root@ub1:/tmp/svntest/wd/rep01# svn propset svn:ignore '*' a2/
svn: warning: 'a2' is not under version control

No such luck!



SVN shows this as non-versioned file.

root@ub1:/tmp/svntest/wd/rep01# svn status
?      a2

Ok. Add this to VCS. In the example below we have not used 'dash dash non-recursive' option since we don't have any files underneath this directory. However if we are ignoring a directory which already has contents then we will have to ensure we only check-in the directory. Otherwise the point to this will be lost! It is now apparent that we cannot ignore the directory itself, but just the contents inside of it. That is not so bad since the directory gets checked in only once and will never bother us again.

root@ub1:/tmp/svntest/wd/rep01# svn add a2
A         a2

Now let's try to ignore

root@ub1:/tmp/svntest/wd/rep01# svn propset svn:ignore '*' a2/
property 'svn:ignore' set on 'a2'

It worked! Let's commit. (optional now and can be done later)

root@ub1:/tmp/svntest/wd/rep01# svn commit -m "test1"
Adding         a2
Committed revision 2.

Now let's create a file underneath a2 dir

root@ub1:/tmp/svntest/wd/rep01# touch a2/f1.txt

Check if it exists

root@ub1:/tmp/svntest/wd/rep01# ls -l a2
total 0
-rw-r--r-- 1 root root 0 2009-08-07 13:31 f1.txt

Let's check status

root@ub1:/tmp/svntest/wd/rep01# svn status
<no output indicates ignore is working>

Wow! It worked this time! No output. Let's make sure with find command

root@ub1:/tmp/svntest/wd/rep01# find a2|grep -v ".svn"
a2
a2/f1.txt

Remember that the directory is actually IN version control. It's files will be ignore by the svn status command

This did not work with my windows command line version of SVN. Tortoise SVN did work to ignore files through GUI.

Also, if you already have files present in the directory you will need to move them out. Here is an easy way to do this

mv cache /tmp/
svn update
rsync -r /tmp/cache cache
svn status
touch cache/test.txt
svn status
rm cache/test.txt
svn status

Last of all if you need to list all the properties that you have set, here is the command for it

svn proplist --recursive

And of course one more very last item is to be able to undo the propset. The command for that goes

svn propdel svn:ignore a2/