tpdi
tpdi

Reputation: 35141

SVN: Revert commit while preserving local changes

So I have a local build file.

It shouldn't be in SVN at all, but, it is. (Thanks, previous maintainer!) But changes have been made to the local copy, which only apply to building on the box it's on.

I screw up and do a commit that commits this local build file. Now the SVN repo copy has these local changes; this is bad.

How can I get back to status quo ante, where the local changes are in the local copy, not in the SVN repo, and a subsequent svn update won't overwrite the local changes?

Upvotes: 1

Views: 1962

Answers (4)

ecstaticpeon
ecstaticpeon

Reputation: 568

If your file shouldn't be versioned, you can un-version it:

svn rm --keep-local filename

This will keep any local file, but SVN will stop tracking it.

Upvotes: 0

A.H.
A.H.

Reputation: 66223

For me this one works:

> svn st
M       0027
> svn info 0027 | grep URL
URL: svn://localhost/xxx/trunk/0027
> svn rm -m "remove accidently checked in file" svn://localhost/xxx/trunk/0027
Revision ...
> svn update
   C 0027
At revision 42.
Summary of conflicts:
  Tree conflicts: 1
> svn revert 0027
Reverted '0027'
> svn status
?       0027

So file 0027 is still alive, has it's old contents but is not in the repo anymore.

Upvotes: 0

Lazy Badger
Lazy Badger

Reputation: 97280

  1. You can not store in WC "local only" changes, if changed files are versioned (except adding set to ignore-list)
  2. You can undo any previous commit(s) by reverse-merging

Upvotes: 0

JB Nizet
JB Nizet

Reputation: 691635

  1. backup the file with the local changes somewhere.
  2. do a show log on the file, and revert this file to the revision before the unwanted changes (using an update with the given revision number)
  3. commit the file
  4. update the whole working copy
  5. restore the backup done at step 1

You might use changelists or lock the file to avoid making the same mistake again.

Upvotes: 2

Related Questions