Etikettarkiv: svn

Adding to SVN without import

Add project files to svn without using import to be able to use ignore.

Since there is no svn meta info about the files yet before the files have been imported there is no way to use ignore to skip for example a huge media folder when using import. Hen and egg situation.

Instead we use svn add in a special way. Maybe you do like this all the time but it took me some head scratching to figure out.

In the example below we have a live webroot that will be ”svn enabled”. Don’t forget to block .svn directories in the web server when checking out a working copy to a live web folder!

1. Create an empty folder ”webroot” in the project repository, typically /trunk/webroot. Let it be empty.

2. Go to a level above the webroot folder on the live server, so webroot is listed when doing ls.

3. Check out the empty webroot folder over the live webroot

svn checkout svn://user@svnserver/Projekt/trunk/webroot webroot

Now the webroot is ”svn enabled” and a valid working copy on the live server, but no files are added yet since we checked out an empty folder from the repository.

Existing files in the live web root are untouched.

4. Get into webroot

cd webroot

5. Add the desired svn ignore (don’t forget the dot at the end, it says ”current directory”)

svn propset svn:ignore media .

Verify with

svn propget svn:ignore

It should list ”media”.

6. Add all live files form the web root.

svn add *

 

Here’s the catch: The problem is that this will also add all files in ignored directory since the asterisk overrides the ignore (explicit adding overrides ignore and the asterisk expands to a series of explicit adds). Verify with svn status to see that also media has A as in added, and it will be a heavy commit if the media directory is large.

7. Fix this by reverting the add of the directory we wanted to ignore.

svn revert –recursive media

Verify this with

svn status –no-ignore

Media is now listed with an I as in ignore. Great!

8. Commit the live web files from the webroot

svn commit -m ”Initial import from live server”

Read more here

http://episteme.arstechnica.com/eve/forums/a/tpc/f/6330927813/m/427002825931