You could do:
svn revert -R .
This will not delete any new file not under version control. But you can easily write a shell script to do that like:
for file in `svn status|grep "^ *?"|sed -e 's/^ *? *//'`; do rm -rf $file ; done
赞
踩
参考下面两个问答:
http://stackoverflow.com/questions/8139605/does-svn-have-a-revert-all-command
-----------------------------------
You could do:
svn revert -R .
This will not delete any new file not under version control. But you can easily write a shell script to do that like:
for file in `svn status|grep "^ *?"|sed -e 's/^ *? *//'`; do rm -rf $file ; done
-----------------------------------
There is a command
svn revert -R .
In addition
If you want to revert a whole directory of files,you can use the --depth=infinity option:
svn revert --depth=infinity
svn revert
is inherently dangerous, since its entire purpose is to throw away data—namely, your uncommitted changes. Once you've reverted, Subversion provides no way to get back those uncommitted changes
-----------------------------------
-----------------------------------
Used a combination of other peoples answers to come up with this solution
svn revert -R .
svn status --no-ignore | grep -E '(^\?)|(^\I)' | sed -e 's/^. *//' | sed -e 's/\(.*\)/"\1"/' | xargs rm -rf
svn update --force
-----------------------------------
None of the answers here were quite what I wanted. Here's what I came up with:
- # Recursively revert any locally-changed files
- svn revert -R .
-
- # Delete any other files in the sandbox (including ignored files),
- # being careful to handle files with spaces in the name
- svn status --no-ignore | grep '^\?' | \
- perl -ne 'print "$1\n" if $_ =~ /^\S+\s+(.*)$/' | \
- tr '\n' '\0' | xargs -0 rm -rf
Tested on Linux; may work in Cygwin, but relies on (I believe) a GNU-specific extension which allows xargs to split based on'\0'
instead of whitespace.
The advantage to the above command is that it does not require any network activity to reset the sandbox. You get exactly what you had before, and youlose all your changes. (disclaimer before someone blames me for this code destroying their work) ;-)
I use this script on a continuous integration system where I want to make sure a clean build is performed after running some tests.
Edit: I'm not sure this works with all versions of Subversion. It's not clear if thesvn status
command is always formatted consistently. Use at your own risk, as with any command that uses such a blanketrm
command.
-----------------------------------
- svn status | grep '^M' | sed -e 's/^.//' | xargs rm
-
- svn update
Will remove any file which has been modified. I seem to remember having trouble with revert when files and directories may have been added.
-----------------------------------
-----------------------------------
转自:http://alanland.iteye.com/blog/2064240
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。