Roll back or revert entire svn repository to an ol

2019-01-12 17:10发布

I messed up on my SVN repository and now need to revert the entire repository from revision 28 to 24 and don't want to deal with diffs or conflicts. Is there a quick and simple way to do this? I've been able to revert back single files before fine with the merge command - but in this instance it wants to add all of the files back into the repository from revision 28 when all I really want to do is delete them.

I am using the command line on a linux box (bash).

Thanks

EDIT

Thanks for all of the help! I fixed it by:

svnadmin create /svnroot/<repo>.fixed
svnadmin dump -r 1:24 /svnroot/<repo> --incremental > dump.svn
svnadmin load /svnroot/<repo>.fixed < dump.svn

Then putting the old repo in a backup location and moving the repo.fixed to repo.

Thanks again!

标签: svn revert
14条回答
我想做一个坏孩纸
2楼-- · 2019-01-12 17:18

I'm not entirely sure if this work as I haven't used it in a live production yet, but I just now tried on a test repository (I copied one of my production ones) and it seems to work.

When you're in your repository, use the following command:

svn update -r 24 trunk

Where 24 is the revision number, and trunk is the file/folder you'd like to update (or restore, in this case) to said revision number.

In my test, several files were updated and (re-)added, and after doing a commit I did not receive any warnings whatsoever. I then modified a file with some dummy text and tried yet another commit, and only said file popped up on the modified list. So it seems to work rather well!

Again, I didn't use this before in live productions, so if I'm wrong please advice. I'd love to know if this is the way to go, too, because I can see myself needing this in the (near) future.

-Dave

查看更多
地球回转人心会变
3楼-- · 2019-01-12 17:25

If you really want to completely remove files from the repository, you need to do an svndump into a file, filter out the revs and/or file paths you don't want, make a new repo, and svnload the filtered dump into the new repository. You'll want to carefully read the SVN book section on repository maintenance before you do any of this, and make sure you don't remove the existing repo until you're sure the new one has the stuff you want.

查看更多
我想做一个坏孩纸
4楼-- · 2019-01-12 17:25

here is how I would start to do it. Brutal, yes, but its the only thing guaranteed to completely ignore collisions and keep revisions history intact.

  cd /scratchdir 
  svn co -r good svn://repository
  cd /hosed_project
  svn up -r HEAD
  cat >> /tmp/cp.sh 
  ORIG=$1
  TARG=$( echo $ORIG | sed 's/\/scratchdir\///' ); 
  cp $ORIG /hosed_project/$TARG;
  ^D
  chmod u+x /tmp/cp.sh
  find /scratchdir -not -wholename "*/.svn*" -exec /tmp/cp.sh {} \;

Note, this is not the "normal" way IMO, the normal way is to create a branch from an old version, and then merge that branch back in to the head. ( at least, that's how It used to work )

Edit: the above code is untested, do NOT run it verbatim

查看更多
forever°为你锁心
5楼-- · 2019-01-12 17:27

If you have access to the SVN server, you can just edit path/db/current, put the old revision number you want to revert to (here: 24) there, and remove no longer needed revision files (i.e. 25, 26, 27, 28) from path/db/revs/0/. At least this worked for me today, after I had accidentally removed a directory in the repository.

查看更多
Bombasti
6楼-- · 2019-01-12 17:28

A "reverse" merge may be what you need. See "undoing changes" section of svn book.

E.g. svn merge -r 28:24 [path to svn]

查看更多
▲ chillily
7楼-- · 2019-01-12 17:29

Check out svnadmin dump/load. It creates a text file with every version of your files. It may be possible to delete everything above/below a certain point and re-import it.

See for instance Migrating Repository Data Elsewhere

查看更多
登录 后发表回答