Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
    
I don't know about svn, but github allows you to download .tar.gzs of a git repo. –  Macha Nov 29 '09 at 13:54
add comment

5 Answers 5

up vote 9 down vote accepted

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.

share|improve this answer
add comment

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/
share|improve this answer
    
Very nice! I didn't know about that option‌​. –  Peter Murray Jul 7 '10 at 15:16
add comment

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).

share|improve this answer
add comment

I see as well:

tar cvfz archive.tar.gz directory/  --exclude='*/.svn'

Thanks tar.

share|improve this answer
add comment

If I understand correctly, you're wanting to tar the results of an svn checkout?

So, in pseudocode, it'd look something like this:

svn export branch; find branch | grep -v '/.' | xargs cp tarbranch ; tar -zcf tarbranch.tgz tarbranch
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.