69

I know I should be working on a branch of my own but a couple of us are on the same branch of a project. One of the Dev's made a commit and I just wanted to update my local copy with the latest from SVN. Running 'svn update' I get this output:

Restored 'index.html'
U    somescript.php
Conflict discovered in file.xml'.
Select: (p) postpone, (df) diff-full, (e) edit,
        (mc) mine-conflict, (tc) theirs-conflict,
        (s) show all options: 

Is there an option/way to overwrite my local changes and get the latest file(s) from subversion and ignore all the conflicts?

I've looked at some of the other posts on Stack and they all don't answer the question. They say to delete the project and checkout again, which I guess if that's the best way so be it... But wanting more details as to why I can't force an update. Thanks

EDIT:

So I selected s 'show all options':

(s) show all options: s

  (e)  edit             - change merged file in an editor
  (df) diff-full        - show all changes made to merged file
  (r)  resolved         - accept merged version of file

  (dc) display-conflict - show all conflicts (ignoring merged version)
  (mc) mine-conflict    - accept my version for all conflicts (same)
  (tc) theirs-conflict  - accept their version for all conflicts (same)

  (mf) mine-full        - accept my version of entire file (even non-conflicts)
  (tf) theirs-full      - accept their version of entire file (same)

  (p)  postpone         - mark the conflict to be resolved later
  (l)  launch           - launch external tool to resolve conflict
  (s)  show all         - show this list

I guess I should go with option 'tc'?

Phill Pafford
  • 83,471
  • 91
  • 263
  • 383
  • Why would you want to do this? Do a merge and you wont loose your changes. Otherwise do a `svn revert` and then `svn up`. – halfdan Sep 14 '10 at 13:17
  • the point is I don't need my changes and wanted to get the latest version for that file and overwrite my changes – Phill Pafford Sep 14 '10 at 13:19
  • Why don't you delete the file and get the recent version just by updating? :) – Select0r Sep 14 '10 at 13:23
  • That is one way, but what if I had a couple of hundred files and I didn't want to delete the project or delete the file(s), is there a way I could 'svn update' to get the latest version? – Phill Pafford Sep 14 '10 at 13:30

5 Answers5

89

If you really want a copy of HEAD (the latest revision in repos), then you should

svn revert -R <path> // discard all your changes inside path (recursive)
svn update           // get latest revision of all files (recursive)

That's it.

Beware that you will lose ALL your changes since your last 'commit'.

EDIT: added the -R <path> from Isu_guy answer for the sake of completeness and helping readers find a single full answer

Community
  • 1
  • 1
tato
  • 5,439
  • 4
  • 31
  • 27
  • 1
    Unversioned files are not removed. See also here: [Is there a Subversion command to reset the working copy?](http://stackoverflow.com/a/6204618/1996150) – Mariano Paniga Dec 17 '15 at 14:29
30

I'd do this:

svn up --accept tf

or

svn up --accept theirs-full

That said, "svn revert -R" then "svn up" at the root of your working copy would also do the trick. In my case, I have several WCs for various projects, so I run a shell script that updates all the them when I start up my computer. I don't use accept, rather I use "--accept p" to postpone resolution since it's an automated process, then I merge any conflicts that SVN can't automatically merge on it's own (usually, this involves reverting, but it depends).

iosMentalist
  • 3,066
  • 1
  • 30
  • 40
Carnix
  • 543
  • 6
  • 14
  • strange - might be SVN client/version specific. I'm running the current version of TortoiseSVN on Win7, however this command also works on the SVN server we have on our CentOS servers too. – Carnix Jul 16 '13 at 13:33
28

tato's answer is absolutely correct and please heed his caution. You will lose ALL your changes. Just a clarification on syntax and some nuances

svn revert is non-recursive by default and needs a path to work on. To make is recursive add "-R". If you are in the current directory use "./" for the "path" below or use an absolute path like "/path_to_your_folder"

svn revert -R <path>

svn update is recursive. If you are in the directory you don't need a path at all

svn update
chris
  • 16,324
  • 9
  • 37
  • 40
lsu_guy
  • 1,525
  • 15
  • 12
17

Using svn 1.6.11 (as shipped by CentOS 6.4) Carnix's command should look like

svn up --accept theirs-full

(cant add a comment since I don't have enough reputation)

Andrei Nistor
  • 535
  • 5
  • 9
2

Answering your first question. No. But you can override your local files by running the following commands from the root of your project:

svn revert -R .
svn update

This worked on my mac with svn 1.7.19 and ubuntu with svn 1.8.8

Alexandre Santos
  • 8,170
  • 10
  • 42
  • 64