问题
I want to write a batch file that can auto commit missing file recursively. how to write the batch command? please helps.
回答1:
The following batch script should SVN delete and commit all files marked as missing (i.e. deleted locally but not using SVN delete):
@echo off
svn status | findstr /R "^!" > missing.list
for /F "tokens=2 delims= " %%A in (missing.list) do (
svn delete %%A && svn -q commit %%A --message "deleting missing files")
Missing files are shown by svn status
with the character !
, for example:
! test.txt
This script then uses findstr to filter out any modifications other than missing files. This list of missing files is then written to a file, missing.list
.
Next, we iterate through this file, using tokens=2 delims=
to remove the !
from the lines in the file, leaving us with (hopefully) just the filename. Once we have the filename, we pass it to svn delete
and then svn commit
. Feel free to change the contents of the message.
Please note that I have not tested this script. In particular, I don't know what happens if one of the files you wish to commit has a space in its path, or what happens if you encounter a conflict part of the way through. It may be better to replace svn delete
and svn commit
with echo svn delete
and echo svn commit
, so that you can see what this script is about to do before you let it loose on your repository.
回答2:
Use svn rm $( svn status | sed -e '/^!/!d' -e 's/^!//' )
See http://geryit.com/blog/2011/03/command-line-subversion-practices/ for more command line subversion
回答3:
just execute the following commands in the root of your working copy:
svn add . --force
svn commit -m"Adding missing files"
回答4:
I made little change for my work..
@echo off
cd c:\project
for /f "usebackq tokens=2*" %%i in (\`svn st ^| findstr /R "^!"\`) do svn del "%%i %%j"
then
svn commit . -m test
It works for me. Thanks.
回答5:
Arst,
for /f "usebackq tokens=2*" %i in (svn st ^| findstr /R "^!") do svn del "%i"
is almost right, but you forgot to wrap the parenthesized commands with back ticks:
for /f "usebackq tokens=2*" %i in (`svn st ^| findstr /R "^!"`) do svn del "%i"
Thanks for the concise command, in any case.
来源:https://stackoverflow.com/questions/5040125/svn-commit-missing-file-automatically