is it possible for subversion to ignore all directory contents except one file?

1k views Asked by At

I have a /packages directory with one file in it that I want to commit and watch. However, if new things are added, I'd like to ignore them. Is that possible?

5

There are 5 answers

0
Satii On

It can be done using pre-commit hook feature. You can ignore all the file names other than that file to get committed. See this link for more information http://pear.php.net/manual/en/package.php.php-codesniffer.svn-pre-commit.php

0
Ashwin Bhargava On

Add a custom hook which will work only on that file. You may code that as a batch file or a perl file. Put the file in your subversion custom hooks folder or hooks folder and the code may be running on post commit that you get notified only for that file not the others in that folder.

0
gbjbaanb On

You could always try using the changelists feature - place all the other files on your ignore-on-commit changelist and they won't bother you again. This might not be quite what you want though.

You can however exclude files using the sparse directory feature, setting the depth to "exclude". This works with individual files (well, it does using TortoiseSVN and the 'make depth sticky' option - the file will disappear from your working copy, not coming back if you update, unless you reset the directory depth)

Be careful to set the depth on the files, not the directory. Any files subsequently added will appear in your directory and you'll have to exclude them too. It's probably possible to set the directory to exclude everything and then re-include just the 1 file you want - I haven't tried that, let us know if it works.

1
Ben On

If a file matches the ignore pattern, nothing prevents you from manually adding that file to SVN. Then SVN will track that file as normal, you can commit changes and see modifications without difficulty. The only thing the ignore list affects, is new files that are not under revision control.

1
G J On

I am using Tortoise git and i have ignored the packages via. .gitignore file as below. If I make changes in repositories.config file, the changes window shows it:

# Visual Studio Nuget package directory
packages/*/