Ignore files and folders via TortoiseSVN

Why ignore?
Ignoring a file or folder from the Subversion system can reduce a lot of complexity from the repository. For example, if you edit your code via NetBeans, you probably don’t want to version control the .nbproject folder it puts into the root of your application. Also you probably don’t want to version logs (that caused me a big headache on my first Rails application as I found I was version controlling a very large (gig!) development.log file after I made a looping error)

Ignoring new items
It is very easy to ignore new items using TortoiseSVN. Simply right click on the object (file or folder) and select:

TortoiseSVN > 'Add to ignore list'

and select the object name presented. Job done.

Editing the result
You can edit the result by right clicking on the object’s containing folder and selecting

TortoiseSVN > Properties

You should see a line in the properties showing the ignore statement that has been added. Click on the Edit button to have a closer look:

Details of SVN properties showing an ignore example

Details of SVN properties showing an ignore example


Note that each pattern being ignored has its own line. If you wanted to add the ‘log’ folder, you could just add a new line with the word log in it. You can also use the * character to add filed cards. For example, if you add

svn:ignore *

to the log folder, the folder itself will be versioned, but not its contents.

Where to ignore
I’ve found it is best to ignore at the level of the containing folder. So if you had a file upload system that stored files in public/file_upload and you wanted to ignore that folder: the best policy is to add an

svn:ignore file_upload

to the public folder and NOT try to

svn:ignore public/file_upload

at the application root.

Recursive
Also be very careful of your use of the “Apply property recursively” option. Selecting this option will over-write the ignore list in all sub-folders so use with caution. In most cases you should not select this option.

Ignoring object already in the repository
You may well find that you have to retrospectively ignore an object because the object is versioned before you realise that it would be better to ignore it. I didn’t find it immediately obvious how to do this.

TortoiseSVN does not allow you to use the methods described above to ignore an object that is already in repository. You have to remove the object from the repository first. Do not use the delete option in the TortoiseSVN right click menu as this will remove the object from the repository AND delete the object itself. Instead use the Repository browser to delete the object from the repository directly.

ToirtoiseSVN > Repo-Browser

Then within the Repository browser right click on the object and select Delete.

Once the object is removed from the repository, the ignore options become available in the TortoiseSVN right click menu.

This entry was posted in Ruby. Bookmark the permalink.