Revert svn files by file pattern

回眸只為那壹抹淺笑 提交于 2019-12-04 06:38:27

问题


I'm trying to find a command (can be bash command) to revert a group of svn files.

Let's say I have some changes in my check-out and I run svn st and get this output:

My-MacBook-2:trunk aetzioni$ svn st
M    SomeFolderA/src/main/java/com/mycompany/package/classA.java
M    SomeFolderA/main/java/com/mycompany/package/classB.java
M    SomeFolderB/src/main/java/com/mycompany/package/classC.java

Now I want to find a command that does svn revert on all the files under SomeFolderA.

I tried something like this:

svn st | grep SomeFolderA | svn revert

But got this error message:

svn: Try 'svn help' for more info
svn: Not enough arguments provided

回答1:


The way I finally did it is by creating this command:

svn st | grep SomeFolderA | awk {'print $2'} | xargs svn revert

Explanation:

  1. svn st - Finds all the modified file
  2. grep SomeFolderA - Filters the svn output to only show lines that have SomeFolderA
  3. awk {'print $2'} - removes the M at the beginning of each output line
  4. xargs svn revert - The xargs command uses the output from previous command and passes it, as is, to the svn revert command


来源:https://stackoverflow.com/questions/19374993/revert-svn-files-by-file-pattern

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!