Automatically remove Subversion unversioned files

前端 未结 30 3164
感情败类
感情败类 2020-11-28 18:54

Does anybody know a way to recursively remove all files in a working copy that are not under version control? (I need this to get more reliable results in my automatic build

30条回答
  •  旧时难觅i
    2020-11-28 19:04

    @zhoufei I tested your answer and here is updated version:

    FOR /F "tokens=1* delims= " %%G IN ('svn st %~1 ^| findstr "^?"') DO del /s /f /q "%%H"
    FOR /F "tokens=1* delims= " %%G IN ('svn st %~1 ^| findstr "^?"') DO rd /s /q "%%H"
    
    • You must use two % marks in front of G and H
    • Switch the order: first remove all files, then remove all directories
    • (optional:) In place of %~1 can be used any directory name, I used this as a function in a bat file, so %~1 is first input paramter

提交回复
热议问题