0

How exactly svn update work? I know that it brings all the changes on the svn copy into your local one.

I have out-of-date file that prevented my copy to be committed with the error:

file 'somename' is out of date

The most occurring solution on SO is to do an svn update command and then svn commit.

But, wouldn't that let me lose the changes I made on my files on my local copy including the out-of-date one?

hasan
  • 23,815
  • 10
  • 63
  • 101

2 Answers2

3

Does it "let you" lose your changes? Sure, I guess. Is it likely to lose your changes? Not at all. Will it silently clobber your changes? Absolutely not.

Doing an svn update will merge the repository changes into your working copy. Assuming you are working with textual files, this means if you made changes to the same lines as the repository changes, you will get a "merge conflict" which you must manually resolve. Thus if you lose your changes, it's because you messed up while resolving conflicts, not because of anything SVN did.

Ben
  • 8,725
  • 1
  • 30
  • 48
0

You can take a backup of local file and get the svn update. Later use any file comparison tool to merge back your changes. Beyond Compare is usually what I use to merge large files. Or else if you are using eclipse with SVN plugin it is much more simpler. Right click on project or file go to Team > Synchronize with Repository. You will see Team Sync view in that you should see your file under outgoing changes or in conflict. Double click on file to be merge and then merge svn file with local. Once everything is done right click on file and Click on Mark as Merged. Finally check in the file.

pratikpawar
  • 2,038
  • 2
  • 16
  • 20
  • Then it is the only way to solve the out-of-date error? – hasan Jul 29 '15 at 08:03
  • I have never got out-of-date error as such. I am assuming it is because local version of file is different than one on SVN. You can simply check the history of file on SVN for current version and se if local file has same version. If you are committing any file on SVN with local version not same as on SVN that is not correct. You may overwrite someone else's changes. Its always safe to follow above approach. I am using eclipse with SVN plugin for check ins; I believe files in conflicts are the ones with out-of-date errors. – pratikpawar Jul 29 '15 at 08:08
  • But, if I want to do that? I want replace mine with the one on svn server – hasan Jul 29 '15 at 08:12
  • It looks like that your answer is the only solution! – hasan Jul 29 '15 at 08:13
  • 2
    This is misleading. `svn update` automatically merges the changes on the server into your local file. If it cannot be done automatically, the file is "conflicted" and you get a chance to resolve the conflicting parts. You will only lose your changes if you mess up when you merge. – Ben Jul 29 '15 at 13:55