当前位置:   article > 正文

svn revert 还原整个目录_revert -rf

revert -rf

参考下面两个问答:

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

-----------------------------------

http://stackoverflow.com/questions/1239998/how-can-i-remove-all-my-changes-in-my-svn-working-directory

-----------------------------------

Used a combination of other peoples answers to come up with this solution

revert normal local svn changes

svn revert -R .

remove any other change and supports removing files/folders with spaces, etc.

svn status --no-ignore | grep -E '(^\?)|(^\I)' | sed -e 's/^. *//' | sed -e 's/\(.*\)/"\1"/' | xargs rm -rf

don't forget to get the latest files from svn

svn update --force

-----------------------------------

None of the answers here were quite what I wanted. Here's what I came up with:

  1. # Recursively revert any locally-changed files
  2. svn revert -R .
  3. # Delete any other files in the sandbox (including ignored files),
  4. # being careful to handle files with spaces in the name
  5. svn status --no-ignore | grep '^\?' | \
  6. perl -ne 'print "$1\n" if $_ =~ /^\S+\s+(.*)$/' | \
  7. 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.

-----------------------------------

  1. svn status | grep '^M' | sed -e 's/^.//' | xargs rm
  2. 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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/111016
推荐阅读
相关标签
  

闽ICP备14008679号