Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 11 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 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

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

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

I see as well:

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

Thanks tar.

share|improve this answer

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

This is adapted from a one-liner I wrote. It assumes you have a ~/tmp directory. You'll need to change the PROJ and URL variables in the first two steps. The rest should work.

For easy copying:

PROJ='yourproj' && URL='$PROJ' && REV=`svn info $URL | fgrep Revision | cut -d ' ' -f 2` &&  cd ~/tmp &&  svn export $URL $PROJ && tar czv -f $PROJ.r$REV.tar.gz $PROJ && rm -r $PROJ.r$REV

For easy viewing:

PROJ='yourproj' && 
URL='$PROJ' && 
REV=`svn info $URL | fgrep Revision | cut -d ' ' -f 2` &&  
cd ~/tmp && 
svn export $URL $PROJ && 
tar czv -f $PROJ.r$REV.tar.gz $PROJ && 
rm -r $PROJ.r$REV
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .