Cleaning Subversion Working Copy

    Colleagues, I want to bring to your attention a small script (PowerShell) that deletes from the working copy of Subversion all files that are not included in the repository:

    powershell -command "(svn status --no-ignore)
      | ? {$ _ -match '^ [I \?]'}
      | foreach {$ _ -replace '^. \ s +'}
      | rm -recurse -force "
    


    And here is a modification that leaves * .suo and * .user files :

    powershell -command "(svn status --no-ignore)
      | ? {$ _ -match '^ [I \?]' -and $ _ -notmatch '\ .suo $ | \ .user $'}
      | foreach {$ _ -replace '^. \ s +'}
      | rm -recurse -force "
    


    What is it for? Sometimes it is very useful to do a clean build, and the svn update command on a large project works much faster than svn checkout .

    Acknowledgments

    The idea belongs to my good friend who categorically refused to mention it :)

    Also popular now: