Adding Files to Subversion without Ignoring svn:ignore
An explanation of why and how to fix the problem of ignored files being added to subversion under some commands.
posted on Mar 26th
While writing a script today to automatically add files to a local repository, I ran across a curious behavior of Subversion. Specifically, while using svn:ignore on certain files, those files were then still added via the command svn add *. In other words, the 'ignored' files were being added as if there weren't 'ignored' at all. However, svn status displayed their ignored status perfectly. Here is the setup:
We're in good shape up to this point. We've added a new directory with 2 new files. We went ahead and added the svn:ignore property for one of the files. As you can see, the svn status properly shows that the file is to be ignored. Now consider this:
And there it is. While I use the wild card (*) to mean all files in the directory, I expected that the svn:ignore files to be removed from that list. I read one explanation that said that the wild card operator is interpreted by linux as ALL files, who aptly returns the full file list to subversion, which just goes on its merry way adding all the files. This isn't a bug on subversion, however. Instead, the above method (the svn add line) is the incorrect way to handle these situations. The correct method is to do the following in place of the above svn add command.
Perfect. To get around the use of the wild card, we simple re-add the entire
'new_dir' directory. Normally this would throw the error:
"svn: warning: 'new_dir' is already under version control"
but the --force option tells it to go ahead and add everything anyways.