Native Commands

  • Produce a patch file of changes commited in revision 1377:

    $ svn diff -r 1376:1377 > diff.patch
    
  • Merge revision 3403 of the trunk into the “1.0” branch:

    $ cd branches/1.0
    $ svn merge -c3403 https://svn.example.com/my_project/trunk
    $ svn commit -m "Merge r3403 into the 1.0 branch."
    
  • Revert current local folder to revision 666:

    $ svn merge -rHEAD:666 ./
    
  • Create an empty repository:

    $ svnadmin create ./my-repo
    
  • Dump a repository (a sure way to migrate a subversion repository from one version to another):

    $ svnadmin dump ./my-repo > ./my-repo.dmp
    
  • Migrate a remote Subversion repository without creating an intermediate dump file:

    $ ssh -C user@myserver.com "svnadmin dump /home/user/my-repo" | svnadmin load /home/user2/my-new-repo
    
  • Launch a standalone Subversion server listening on port 3690 and serving all repositories located in ./repos/:

    $ svnserve --daemon --listen-port 3690 --root ./repos/
    

Local Working Copy Hacking

  • Recursive and case insensitive content search on non-binary files from the current folder, while ignoring .svn folders and their content:

    $ find ./ -type f -not -regex ".*\/.svn\/.*" -exec grep -Iil "string to search" {} \;
    
  • Same thing as above but with an alternative approach (that don’t work with large folder content):

    $ grep -Ii "string to search" $(find . | grep -v .svn)
    

Other alternative: use ack.

  • Use sed to replace text in all files except in subversion metadatas:

    $ find ./ -type f -not -regex ".*\/.svn\/.*" -print -exec sed -i 's/str1/str2/g' "{}" \;
    
  • Use svn delete to remove all files containing a tilde in their name without touching local subversion metadatas:

    $ find -type f -not -regex ".*\/.svn\/.*" -name "*˜*" -print -exec svn delete "{}" \;
    
  • In a repository structure containing sub-projects (thinks of Plone’s collective repository as an example), get the list of all folders in all trunks, while ignoring subversion metadata folders:

    $ find ./ -type d -regex ".*\/trunk\/?.*" -not -regex ".*\/.svn\/?.*" -print
    
  • Similarly to the command above, replace all occurrences of the string @coolcavemen.fr by @coolcavemen.com in all trunk subfolders while ignoring .svn content:

    $ find ./ -type f -regex ".*\/trunk\/.*" -not -regex ".*\/.svn\/.*" -print -exec sed -i 's/@coolcavemen\.fr/@coolcavemen\.com/g' "{}" \;
    
  • Set a svn property to ignore all .mo files during commit in every folder of our local working copy containing .po files:

    $ find ./ -type f -name "*.po" -regex ".*\/trunk\/.*" -not -regex ".*\/.svn\/.*" -printf "%h\n" | uniq | xargs svn propset "svn:ignore" "*.mo"
    

Related content