Using TortoiseSVN to Export Only New/Modified Files

Though many teams are using Subversion (SVN) to work together and share code, version control software provides a huge number of features that are not often used.  Just about any developer these days knows how to checkout a project and commit or revert changes.  But a lot of teams don’t really use more advanced features like branching and tagging to organize releases.

The great thing about version control systems like SVN is that you gain a bunch of really useful functionality – even if you have only been using it for sharing code.  One of those features is the ability to create an export of all modified files since the previous release.  A common scenario is when the team is working on a web application and it’s time to deploy all the recent changes to the production server.  An app that is distributed would normally use tags or branches to keep the versions straight.  But some teams prefer to just keep moving forward on the HEAD revision and never look back.  If this sounds like you, luckily SVN provides an easy way to get all changed files since your last deployment and package them up with just a few clicks.

Lets say that you last deployed your application from repository version #85.  After a few weeks of development, the repository is now up to revision #178.  The team has decided that the code is stable and you are ready to package up all new/changed files to transfer to the host server, client, etc.

  1. Using TortoiseSVN, right-click on your working folder and select “Show Log” from the TortoiseSVN menu.
  2. Click the revision that was last published (#85 in this example)
  3. Ctrl+Click the HEAD revision (or whatever revision you want to release ie #178) so that both the old and the new revisions are highlighted.
  4. Right-click on either of the highlighted revisions and select “Compare revisions.”  This will open a dialog window that lists all new/modified files.
  5. Select all files from this list (Ctrl+a) then right-click on the highlighted files and select “Export selection to…”

You’ll be prompted for a location to save your updated files and SVN will export them all with the directory structure preserved.  You can then zip this up for your client, transfer it to your host or whatever you normally do to deploy the application.

Some teams prefer to actually do an update right on the production server and simply checkout the files that way.  If your hosting setup permits and you don’t mind the “.svn” files in on your server, that is another easy option for deploying code.

For even more automation, this could all be done using batch, shell or ant build scripts such as svn-export-changes.  If you know of another solution, please feel free to post it in the comments.

54 Responses to “Using TortoiseSVN to Export Only New/Modified Files”

  1. BrettN September 11, 2007 at 6:20 pm #

    Thanks for the post, this would appear to be exactly what I need, but I have yet to get it to work.

    The TortoiseSVN windows client does not allow the export of files, only directories.

    How did you get around this? What version of SVN client are you using?

  2. Jason September 15, 2007 at 2:28 pm #

    Hey Brett, I usually upgrade TortoiseSVN about every few months or whatever, but I’m not running any bleeding edge beta code or anything – I think the export features have been there for a while.

    As far as the export goes – this method exports anything that has changed between revisions and it preserves the directory structure. So you have the whole folder.

    If you just want the files w/o any directory structure, I’m not sure the reason you would want that, but one trick that I use in windows to “flatten” a directory structure is just use windows explorer search function to search within the folder for “*.*”. Search will return a list of all files which then you can copy the results to a single folder.

  3. Joao January 3, 2008 at 12:37 am #

    I was doing this in Win XP and it was great. Does anyone know of a SVN client that can do the similar in Linux (eg. Ubuntu 7.10)?

  4. Jason January 5, 2008 at 11:02 pm #

    I think most Linux people use the command line for SVN, but there are a few front end apps http://sourceforge.net/projects/esvn (opens source) and http://www.syncrosvnclient.com/ (commercial)

    I’m not sure how to export only changed files between revisions from the command line but I would definitely like to know. If anybody knows, please feel free to leave a comment.

  5. Wik February 1, 2008 at 5:40 pm #

    About exporting only changed files between revisions from the command line.

    I tried to implement it with simple shell script:
    http://osmonitoring.com/mofio/

    Hope this helps.

  6. William ? Brasil May 14, 2008 at 11:24 pm #

    Thanks for this useful post!

  7. Mike July 4, 2008 at 6:37 am #

    Just what I was looking for. Thanks a lot!

  8. hamy July 12, 2008 at 4:43 pm #

    Since TSVN 1.5 came out there are some minor changes. Here is a nice link to quick videos showing how to use basic TSVN features. Hope it helps you as well.

    http://pollvu.blip.tv/

    hamy

  9. Simon October 28, 2008 at 1:09 pm #

    So easy, thanks!

  10. Cristian March 24, 2009 at 10:48 am #

    Great post, it’s what I looking for.

    Best regards.

  11. tony petruzzi April 9, 2009 at 6:55 pm #

    i’ve always wondered how to do this. saved me a ton of time and i thank you for it.

  12. Dimas July 8, 2009 at 8:39 am #

    Great post, help me very much. I’ve retweeted!

  13. Wolfgang July 22, 2009 at 11:51 am #

    Thxs for this great post, it saved us a lot of time.

  14. Jason August 10, 2009 at 12:43 pm #

    Thanks for this excellent tip!

  15. Storm September 21, 2009 at 10:49 pm #

    Thanks for your tip. It’s really cool.

  16. josh tischer November 11, 2009 at 4:14 pm #

    i have spent some time trying to figure this out when i first started using subversion a few years ago and gave up. Thanks for the reminder and solution!

  17. Julien Falconnet November 12, 2009 at 6:19 am #

    A little bash script for those missing Tortoise
    http://www.falconnet.fr/Subversion-export-des-fichiers.html

  18. jeff November 16, 2009 at 1:46 pm #

    this is great. I wish, though, that I could do the same thing while selecting only certain revisions. For instance, I want all revisions having to do with a certain feature dating back 3 months, but don’t want any files associated with other features. Unfortunately the “compare revisions” menu item is not available unless you select all revisions between x and y. Any known workaround?

  19. Jason November 16, 2009 at 2:32 pm #

    hey jeff, you might want to look into tagging – http://svnbook.red-bean.com/en/1.1/ch04s06.html

  20. Weeb February 26, 2010 at 7:16 am #

    you are a star!

  21. Marc March 25, 2010 at 7:27 am #

    Hi,
    Using this method, is it possible to export _all_ directories of the application? So not only the folders containing the changed files but also all other folders – which would be empty of source, since they do not contain any changed files?

    Thanks,

    Marc

  22. Jason March 28, 2010 at 4:27 pm #

    @Marc
    Hey Marc, you can do that just using a regular old export. If you right-click and drag an SVN directory, a menu appears and it has options to export, as well as export everything including un-revisioned files.

  23. Yura Rodchyn (rodchyn) March 30, 2010 at 10:29 am #

    Thanks a lot, I need to update by FTP some changed files and need to have changed files with directory structure. Your method help me.

    Thanks a lot twice!

  24. Peter May 11, 2010 at 10:07 am #

    That is just great! Found a link to this article on another blog.

  25. Hitesh June 7, 2010 at 5:44 am #

    Can any1 please tell me how to get old and new file for a particular revision number in SVN…..

    • Jason June 10, 2010 at 6:55 pm #

      @Hitesh – there’s a lot of ways to do but it depends on what you are trying to do. check the main tortoise site and read up on the history-related commands and that should help.

  26. Allen June 10, 2010 at 6:22 pm #

    Is it possible to mark certain files/folders as not exportable? I have admin files that I dont want on a production server, but I cant find any automated way to remove them before export.

    • Jason June 10, 2010 at 7:08 pm #

      @Allen there’s a lot of tricks for doing that. if you’re talking about config files, the way I do it is similar to the way a lot of teams deploy (wordpress for example). You have a file named something like config.default in version control with default values. When installing the first time the user must copy and rename it to something – for example config.php. And config.php is added to the svn ignore list for the repo so it will never get touched during commit or update. This way you can deploy updates without ever overwriting the config for each server installation.

      If you’re talking just about folders of content that just shouldn’t get deployed, the way I would do it is just put those in a separate repo altogether, or create a branch or something so those files are not part of the deployment code.

      There’s probably other ways to do it. If nothing else, just write a shell script to export and then immediately delete the files/folders you don’t want deployed.

  27. nadshez August 20, 2010 at 2:20 am #

    Thanks a lot! This is exactly what I was looking for, but couldn’t find it all the help file of tortoise. Thanks again.

  28. diego September 30, 2010 at 3:28 pm #

    thanks

  29. Robert October 10, 2010 at 3:14 am #

    Great tip, thanks!

  30. Samaursa October 16, 2010 at 6:55 pm #

    Excellent, exactly what I was looking for (one of those hidden features in SVN). Thanks for posting it up!

  31. Robert October 21, 2010 at 10:35 pm #

    Hi Jason, thanks for this post. Unfortunately this solution do not work for svn:externals. Does anybody know, how to export also the modified files from the externals?

    If this is not possible in (Tortoise)SVN, I would also appreciate a solution with another tool (e.g. WinMerge, etc.).

  32. RSK January 17, 2011 at 12:00 am #

    Thank a lot.
    This is exactly what i searched for. :)

  33. Ofir February 21, 2011 at 12:45 am #

    Hello,

    Thanks for the nice and informative post.

    Is there a way to this with working copy?
    I want to save my changes to zipped file (not commit them) and revert changes.
    Later I’ll use the file.

    Thanks,
    Ofir

    • kbalcerek March 10, 2011 at 2:39 am #

      Hello,

      Same question as above, is it possible to do it with WC and not commit changes? I know we can drag&drop files from “Check for modifications” dialog, but in this way folders structure is not saved.

      The other option is to create patch, but as far as I have noticed patch does not contain binary files.

      What I would like to do is to copy modified/added/non-versioned files to some folder, revert changes on my WC so I could do some other changes and then get back to my problem later copying previously saved folder and overwriting files in my WC. I know there is a branch functionality, but I don’t want to make mess in repository (I thing creating branches for small tasks managed by one developer is not good idea, em I right?)

      Kamil

      • Jason March 11, 2011 at 2:44 am #

        Hey Kamil you have several options for working that way from simply making a backup copy of your new work to branching.

        Branching seems like the correct way based on what you said, but a simple backup copy could be ok if you don’t want version control for your new changes before you are ready.

        You might look into git also, it is meant to do lots of branching easily.

        • Kamil March 16, 2011 at 2:23 pm #

          Jason, thx for your reply. As I have written above I know there is branching functionality in SVN and I know how does it work, but I’m nor sure if creating branches for small tasks (1-3 days of development) is good idea.

          Let me explain my problem in more details. My Team is build of 5 developers, during a week (5 days) each of them is working over 2-4 tasks. So it would give us 10-20 branches in SVN repository. Most of all some tasks takes more then 5 days, so please imagine over 20 opened branches in repository – IMHO it might be little difficult to maintain and it would make repository to rapidly grow up.

          What I would like to do is to export modified files from my WC to easily upload them to draft server. After the changes are confirmed by client the developer would commit them to repository and upload to production.

          Once again, I know branches perfectly fits to what I described above, I’m just wondering if they are required for such a small tasks. Export modified files from WC would fix my problem :)

          • Jason March 16, 2011 at 4:16 pm #

            hey Kamil, i probably don’t fully understand your workflow but you might consider looking into svn tags for these purposes. you can all just check into the head revision without branching and then upon approval you can tag changes for your release.

            however, what you are describing does sound exactly like what git does. you can have tree-like hierarchy of repositories. it’s a slightly different concept. branching is a normal, expected part of git workflow and is meant to be seamless. i have a feeling what you are trying to do is perfect use case for git.

  34. Cyril March 1, 2011 at 4:54 am #

    Very usefull tip, thanks

  35. amila July 1, 2011 at 7:36 am #

    Hi,
    Nice post. Thanks.

    I wanted to do this by using command line. If can please post command for that.

  36. xrigher July 13, 2011 at 7:19 am #

    thx a lot! this is what exactly i wanted.

  37. Rude September 2, 2011 at 3:26 am #

    Thanks a lot, man. I would have expected this function rather in the create-patch dialog.

  38. Claudio December 1, 2011 at 12:58 pm #

    Using Script to Export Only New/Modified Files from SVN revision

    http://www.jroller.com/vagheti/entry/using_script_to_export_only

    • Jason December 1, 2011 at 1:14 pm #

      very cool – thanks!

  39. Geoff March 26, 2012 at 7:14 pm #

    Thanks, this is exactly what I was after… !

  40. David April 11, 2012 at 6:38 am #

    Hi.
    I have the following case: I have two branches (A and B).
    We do commit in B (commit1, commit2,…). After I want copy/export from branch B to branch A a given commit (for example, commit2).
    is it possible???
    Thank you.

  41. AW September 26, 2012 at 7:20 am #

    Old post, but still relevant. Exactly what I needed, thanks!

  42. James Prosser October 17, 2012 at 12:29 am #

    Exactly what I required. Thanks.

  43. Manne November 6, 2012 at 10:27 pm #

    thanks jason…..it really works. now im able to save the files from a revision with folder structure :)

  44. Domenic November 9, 2012 at 2:07 am #

    Hi

    I just wanted to thank for this post. It was exactly what I was searching for!
    For me this is a great way to publish any updates to my productive Server.

  45. Jreading January 24, 2013 at 4:28 pm #

    Here’s my solution for mac/*nix folks!
    https://github.com/jreading/svn-export-changes.sh

    • Jason January 26, 2013 at 8:15 pm #

      fantastic – thanks for posting. I just added a link in the post.

Leave a Reply

Please leave these two fields as-is: