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?
is it possible for subversion to ignore all directory contents except one file?
1k Views Asked by end-user AtThere are 5 best solutions below
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.
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.
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