svn revert restore Entire directory

Source: Internet
Author: User
Tags svn svn update

Refer to the following two questions and answers:

Http://stackoverflow.com/questions/8139605/does-svn-have-a-revert-all-command

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

Could do:

SVN revert-r.

This is not the delete any new file under version control. But you can easily write a shell script to do the 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 are to throw away data-namely, your uncommitted changes. Once you ' ve reverted, Subversion provides no-you-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 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 to 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 ' | xargs-0 RM-RF

Tested on Linux; Cygwin, but relies on (I believe) a gnu-specific extension which allows Xargs to split based on ' instead ' whitespace.

The advantage to the above command is, it does not require any network activity to reset the sandbox. You get exactly the had before, and youlose all your changes. (Disclaimer before someone blames me for this code destroying their work);-)

I use the This script in a continuous integration system where I want to make sure a clean build was performed after running so Me tests.

Edit: I ' m not sure the this works with all versions of Subversion. It's not clear if the THESVN status command is always formatted consistently. Use for your own risk, as with any command that uses such a BLANKETRM command.

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

SVN status | grep ' ^m ' | Sed-e ' s/^.//' | Xargs RM

SVN update

Would remove any file which have been modified. I seem to remember had trouble with revert when files and directories could have been added.

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

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


Transferred from: http://alanland.iteye.com/blog/2064240

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.