How can I delete all unversioned/ignored files/folders in my working copy?

前端 未结 12 1819
忘掉有多难
忘掉有多难 2020-11-28 19:06

If I have a working copy of a Subversion repository, is there a way to delete all unversioned or ignored files in that working copy with a single command or tool? Essential

相关标签:
12条回答
  • 2020-11-28 19:51

    With powershell:

    (svn status --no-ignore) -match '[?]' -replace '^.\s+' | rm
    

    From command line:

    powershell -Command "&{(svn status --no-ignore) -match '[?]' -replace '^.\s+' | rm}"
    
    0 讨论(0)
  • 2020-11-28 19:53

    This is similar to other answers, but actually gets ignored files (note the 'I' in the REs):

     rm -rf `svn status --no-ignore | grep '^[\?I]' | sed 's/^[\?I]//'`
    
    0 讨论(0)
  • 2020-11-28 19:53

    Somebody said you can't do it from the Windows command line.

    Bull.

    for /f "tokens=2 delims= " %I IN ('svn st --no-ignore ^| findstr /R "^[I?]"') DO (DEL /S /F /Q /A:H "%I" & rmdir /S /Q "%I")
    

    Does it in one line and doesn't require a single GNU tool. :)

    0 讨论(0)
  • 2020-11-28 19:55

    Using TortoiseSVN:

    1. Right-Click on the root of the working copy and select TortoiseSVN -> "check for modifications"
    2. Select "Show ignored files"
    3. Sort by "Text status" column
    4. scroll to the "non-versioned" files, now all grouped together; select them all and right-click -> delete
    5. scroll to the "ignored" files, now all grouped together; select them all and right-click -> delete

    Not really a nice and clean solution, but the fastest way I know of (on Windows).

    Thanks to pkh for the tip with the ignored files.

    0 讨论(0)
  • 2020-11-28 19:56

    you can't delete them with just SVN command line (not sure about GUI tools though) if you are under linux system this might help:

    http://www.guyrutenberg.com/2008/01/18/delete-unversioned-files-under-svn/

    The other (brutal) method is to commit changes, delete all from folder and checkout again.

    0 讨论(0)
  • 2020-11-28 19:59

    I know this is old but in case anyone else stumbles upon it, newer versions (1.9 or later) of svn support --remove-unversioned, e.g. svn cleanup . --remove-unversioned.

    https://subversion.apache.org/docs/release-notes/1.9.html#svn-cleanup-options

    0 讨论(0)
提交回复
热议问题