Fix Subversion conflicts

Got a case where you did a @svn up@ and now you have a bunch of conflicts where you just want to overwrite your changes? I’ve got a little bit of Ruby cleverness for you:


  `svn status`.split("\n").grep(/^C/).map { |c| c.scan(/\S+/).last }.each { |c| `svn cat #{c} > #{c} && svn resolved #{c}` }

I run this from @irb@ at the root of my Subversion working directory. It makes me happy.

Update: lord that looks ugly on one line!


  status = `svn status`.split("\n")
  conflicts = status.grep(/^C/)
  files = conflicts.map { |c| c.scan(/\S+/).last }
  conflicts.each do |c|
    `svn cat #{c} > #{c} && svn resolved #{c}`
  end

One response to “Fix Subversion conflicts”

  1. You can do this by reverting too I think:

    ruby -e ‘`svn st`.scan(/^C\s+(.*)/){|f| `svn revert #{f}`}’

    or just: svn -R revert . to revert all