Pages

Ignoring files on svn:import with subversion

Sometimes when I start a project I already have some folder structure and code in place that I want to put into Subversion. However there are also already some files and folders present that I want to ignore on import. Subversion does not provide a way to ignore files on svn:import using the command line. But by using the global-ignores feature you can ignore files on svn:import when you follow these steps.

1. First locate the Subversion config file. Most probably you will find it at ${HOME}/.subversion/config. In the file locate the global-ignores line and add the patterns you wish to exclude from the import, typically these are generated files like .class files etc. For instance in a Maven, Java, Eclipse project you would put: global-ignores = target .classpath .project .settings

2. Run svn:import [PATH] URL. Now everything you put in the global-ignores line is excluded from the import.

3. You still do not have a working copy though since svn:import does not replace the local files with the working copy. To achieve this you can run svn co --force URL [PATH]

4. Now the files you put in global-ignores on your local file system are not ignored on your colleagues machine when they do a fresh checkout. So they could be temped to check-in the generated files. To prevent this you need to add the files to the svn:ignore list of the parent folder using the propset (or propedit) command. To achieve this you first need to comment out the global-ignores line in your config file. Then add the generated files to svn:ignore and check the code in.

This way you can check-in new code into subversion without having to manually remove all the generated files first. It would be nice though if Subversion provided a way to ignore files on import and checkout the code in a single command.

2 comments to Ignoring files on svn:import with subversion

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>