参考下面两个问答:

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 $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:

# 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 you lose 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 the svn status command is always formatted consistently. Use at your own risk, as with any command that uses such a blanket rm 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.

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

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

linux svn revert,svn revert 复原整个目录相关推荐

  1. Linux下搭建SVN服务器及自动更新项目文件到web发布目录(www)

    一.linux服务器端配置 1 2 3 4 5 6 7 8 9 [root@server ~]# rpm -qa | grep sub subversion-libs-1.7.14-10.el7.x8 ...

  2. Linux下SVN命令一次性提交多个目录及子目录

    svn st|awk '{print $2}'|xargs svn add. 乍看之下觉得更加精炼,仔细看下就会发现这个脚本没有区分文件状态.所以完善了以下这个脚本: svn st | awk '{i ...

  3. svn中的revert和update

    svn中的revert和update 今天有人问到revert和update的问题. 刚开始还真被问住了. 因为感觉revert和update都可以将本地的copy更新到以前的一个版本,会有什么不同呢 ...

  4. linux svn上传目录_Linux系统下svn更新自动同步到web目录

    一.在web目录中checkout版本库 这一步算是比较关键的一步了,当时我搭建的时候试了无数次,就是缺少了这一步.把刚才checkout的版本库删掉,我们来一次比较正式的checkout: svn ...

  5. Linux系统下SVN服务器的搭建过程详解 UpJ}s7+

    Linux系统下SVN服务器的搭建过程详解 UpJ}s7+   1 环境:  服务器放在redhatAS4.0上,客户端在windows 2000. k_lb"5z   Z]jSq@%1H* ...

  6. linux离线安装svn客户端和通过命令行使用svn

    目录 参考文献 安装svn客户端 下载 安装 安装apr 安装expat 安装apr-util 安装zlib 复制或移动文件夹sqlite-autoconf 安装subversion 命令行使用SVN ...

  7. Linux下对SVN的相关操作命令

    1.将文件checkout到本地目录          svn checkout path(path是服务器上的目录)          例如:svn checkout svn://192.168.1 ...

  8. U3D+SVN: 两份相同资源放在不同目录下导致META的更改

    U3D+SVN: 两份相同资源放在不同目录下导致META的更改 U3D+SVN: 两份相同资源放在不同目录下导致META的更改. 实际情形:将地图文件map拷一份放在其它目录,回到UNITY编辑器,载 ...

  9. Linux下的SVN命令

    1.   将文件checkout到本地目录 svn checkout path(path是服务器上的目录) 例如:svn checkout svn://192.168.1.1/pro/domain 简 ...

最新文章

  1. Unicode编码问题,编程方面的技巧集合
  2. 结构化的网络故障检测与排除方法
  3. python精通-11周精通python计划(完结)-网易云课堂
  4. mysql连接查询之间的差异性
  5. Tomcat 初始化端点错误--Error initializing endpoint
  6. uva 11367 (Dijkstra+DP)
  7. 依赖注入容器 Castle windsor的使用
  8. 致我们曾经白嫖的网站
  9. Crazy Drops 3
  10. tomcat开启cgi
  11. fastadmin 后台view data-source关联报500错误问题
  12. 程序员如何处理被 “吃” 掉的异常?
  13. html展开收起样式,前端网页内容实现展开/收起全文的操作(js+css控制高度实现)...
  14. 文本分类(2)-基于传统机器学习方法进行文本分类
  15. H5+Android混合开发电视APP
  16. 宝宝为什么不吃奶粉,奶爸必读文章
  17. 以低字节为字地址是什么意思?
  18. Python Pillow批量转换tif格式到jpg
  19. Tian Ji -- The Horse Racing 贪心算法
  20. python生成排列组合_Python 排列组合生成

热门文章

  1. Dynatrace系列之- 监控第三方API调用
  2. SOLIDWORKS 2023 3D Creator 云端结构设计新功能
  3. 乐淘副总裁陈虎:2011是B2C企业兴衰分水岭
  4. iptables防火墙(一)
  5. hdoj 积木堆砌的城堡 1268 (数学几何)
  6. Oracle创建并安装实例失败,11gr2创建实例一直失败,百度无果,求解
  7. CentOS7安装Oracle 11gR2
  8. 国产开源数据库的讲解
  9. 转载:中国十大啤酒品牌介绍
  10. [opencv] cvline cvcircle cvEllipse等画图操作