简体   繁体   中英

Can svn “ignore” deleted files or delete them from repository?

When I try to commit my project to svn I get the following issue

svn: '/var/www/sites/blabla/425/file.png' is scheduled for addition, but is missing

This happens because some material is deleted from the project (and I cannot use svn to delete it). Is there a way to say svn to ignore such files, or just to delete it them if they are not found ?

When you do a svn status , the output will show any such files which are "missing" as a line starting with an exclamation mark:

!       425/file.png

You should write a script (in your scripting language or command line shell of choice) which parses this output, looks for lines starting with an exclamation mark, extracts the filename, and which then does a svn revert <filename> . This will then undo the local change to that file, allowing you to commit without problems.

edit : since you mentioned a php script in a comment, I suppose you are familiar with PHP scripting. In that case you can make use of the PHP function svn_status .

edit2 : if you want to delete the file from the repository, do a svn rm --force <filename> instead.

So you svn add the file but later on deleted it manually? Try;

svn rm --force file.png

to remove it from the SVN index.

从终端运行以下命令:

svn revert $(svn st | awk 'BEGIN{FS=""} $1=="!" && $2 !~ /\.(sql|log|tmpl)$/ {print $2}')

Works for me:

svn status | grep ^\! | awk '{print $2}' | xargs -L1 svn del --force

and if you have whitespaces in your filenames, we cannot use awk so we cut until the start of the filename (You'll probably have to edit this one: because idk if we must cut 9 characters on every system) :

svn status | grep ^\! | cut -c9- | sed 's/ /\\ /g'| xargs -L1 svn del --force

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM