Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force your local version as newest on SVN

Tags:

merge

svn

I made some changes and commited them (to version 2), and found out that they introduced new bugs to my program some minutes later. So I switched to some of the files to an older version to get some of the files back to version 1 on my local platform. Since then I have made a lot of changes I don't want to lose, and I have used commit (version 3) to get my local changes on the server.

The version I have locally is exactly what I want to be on the repository as head revision, even though some of the files are still officially on "version 1". I assume I should be using SVN merge in some way, but I'm not really sure how to do it. Any advice?

edit: When I use diff, it shows changes from the local version to the rep version. I could do update, but then I would have a non-working version locally again. So what I want is some kind of forced commit, that just says "this is the newest version, period".

edit2: When doing "commit", SVN reports that there are no changes. Thanks to Neil Butterworth for the question.

edit3: What I finally did, FYI: I should just have used Tim's suggestion, but I was dumb enough to do an update without really thinking about what I was doing. Of course, everything was then really messed up beyond repair. So what I finally did was to export the project to a new directory. That's obviously not the way you should do it, but I did not want to mess with this stuff any longer. In the end I had to get back to making actual progress on the actual project;-) I know that I can't do stuff like that when I'm working in a bigger team, but I'm not:)

like image 776
panschk Avatar asked Mar 20 '09 10:03

panschk


People also ask

How Do I Get latest in svn?

Simply type svn update [name-of-directory] , or cd to that directory and type svn update there.

Does svn update overwrite local changes?

Subversion is pretty smart about updating and never just overwrites files that have local changes with copies from the repository. The most important thing to take away from this section is: If you collaborate with others on one repository, remember to update your working copy regularly.

How do I commit local changes in svn?

Select any file and/or folders you want to commit, then TortoiseSVN → Commit.... The commit dialog will show you every changed file, including added, deleted and unversioned files. If you don't want a changed file to be committed, just uncheck that file.


1 Answers

Brute force way:

  1. Make a copy of your local files.
  2. Delete all the .svn files in all the directories
  3. Check out the the HEAD version.
  4. Copy your local files onto the checked out HEAD.
  5. Check your local files back into the repository.

If you did it correctly, the SVN client should interpret the changed files as updates to the repository. This will however overwrite any changes other people have made that you may want to keep. If you want to keep those changes, do a diff on all the files first and incorporate all the recent changes, before making the final commit.

Reverse merge back to original revision:

  • For each changed file,
    1. Compare diff, note changes you want to keep, and change your local copy accordingly.
    2. Make a copy of your local files.
    3. Reverse merge HEAD back to desired original version.
    4. Paste your copy of the local files onto the merged local copy. (Delete .svn first)
    5. Commit

This is probably more manual unless you just revert everything back without checking for any changes.

Subversion, AFAIK, has no provision for an obliterate command yet, so all changes always happen to the local copy of the HEAD.

Reverting back is just a reverse merge, and all merges always happen on your local copy. In an ideal system, the merge will be tracked, but Subversion doesn't track merge information, so you might as well do method 1, and just make a comment in the commit log.

Some URLs to look up:

  • Nabble - Subversion Users - Newb help moving to older revision of file
  • Copying Changes Between Branches
  • Common Use-Cases for Merging
like image 160
Tim Avatar answered Sep 28 '22 05:09

Tim