SVN directly to tar
Is there a way to directly tar the latest version of an SVN folder without the SVN hidden files? I would like to create a tar archive without the SVN files. I know you can get the latest with the SVN tracking files, but is there a one liner that will directly send the information to an archive?
Solution 1:
The easiest way to make a copy of the latest version of a repository without all the .svn folders is to use the svn export
command.
Here's how I would make the archive:
$ svn export URL PATH ; tar czf exported_copy.tgz PATH
Where URL is the URL of your svn repository and PATH is a local path suitable for saving a copy of the exported repository. I don't know a way to do it more directly than this. Unfortunately you do end up with the exported copy hanging around, so you might just want to put the whole thing in a short bash script which then deletes the temp files afterwards.
EDIT: While this is the easiest method and is what I used as well I would be careful. In my research I found this http://narfation.org/2009/01/08/creating-recreatable-tar-gz-from-svn which clearly tells us the problem of preserved group/user ownership which causes problems when deploying to another system. I have tried this script with modifications of my own to suit my purpose and you might benefit as well.
Solution 2:
Maybe version 1.23 of tar allows you to exclude all versioning files from command line but unfortunately don't work on my 1.20 version:
tar --exclude-vcs -cvzf archive.tar.gz directory/
Solution 3:
Go to the subversion working directory (checkout) and run this:
find -name .svn -prune -o -print | cpio -o -H tar | gzip > archive.tar.gz
If you're using GNU utilities you can also run:
find -name .svn -prune -o -print0 | cpio -o -0 -H tar | gzip > archive.tar.gz
If possible, I would recommend using the ustar format (-H ustar
).
Solution 4:
I see as well:
tar cvfz archive.tar.gz directory/ --exclude='*/.svn'
Thanks tar.