问题
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:
svn st
- Finds all the modified filegrep SomeFolderA
- Filters the svn output to only show lines that haveSomeFolderA
awk {'print $2'}
- removes theM
at the beginning of each output linexargs svn revert
- Thexargs
command uses the output from previous command and passes it, as is, to thesvn revert
command
来源:https://stackoverflow.com/questions/19374993/revert-svn-files-by-file-pattern