49

I understand that the "SVN checkout" command will do the initial get of file(s) from the Subversion repository and bring them locally to your working directory/copy and that the "SVN update" command will get changes to file(s) from the repository if changes have been made by others.

It seems to me though that an "update" is just a special case of a "checkout", that is, when a checkout occurs, it's getting all files since none yet exist locally and hence ALL of the files have "changed", and that behind the scenes these commands are doing largely the same thing. I assume the commands exist separately just as a means of simplification?

Or, are there other differences between the commands, for example, does "SVN update" get files get new files (files that exist in the repository that you don't have in your working copy) or just updates to existing files?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Emilio
  • 1,951
  • 3
  • 18
  • 24
  • 1
    Also related is the "svn export" command. This will bring down files from a repository, but not create a working copy. You will not be able to commit changes from an export. – Mike Miller Feb 12 '10 at 20:21
  • It's just for read-only, or "browse" type purposes? Where does it put them, some temp dir? – Emilio Feb 12 '10 at 20:25
  • 1
    No it'll be a writable copy, just not containing any hidden .svn directories to track changes. – Dave Van den Eynde Feb 15 '10 at 16:04

6 Answers6

46

As I see it, the big difference is that checkout creates a working copy, whereas update brings down changes to an existing working copy.

karoberts
  • 9,828
  • 4
  • 39
  • 39
  • 8
    IMHO this does not answer the question, because this distinction is already contained within the question. It's pretty obvious that the two commands have different semantics, but how do they differ *technically*? Aren't they effectively doing the same thing, just one at the beginning, and the other one at later point in times? – Golo Roden Feb 15 '17 at 11:15
17

svn checkout copies all the versioned files from the given directory in the repository at the given revision (default HEAD), and copies them to your local machine. It also generates all of the hidden .svn directories, and the meta-data within them, that make these files a working copy.

svn export copies all the versioned files from the given directory in the repository at the given revision (default HEAD), and copies them to your local machine, but produces a standard directory hierachy. (It does not produce a working copy that can be updated or checked back in).

svn update applies changes to an existing working copy. If, in doing so, a conflict is discovered the user is alerted and must resolve this before being able to commit any changes. When using svn commit it is a requirement that the working copy to be committed is up to date (ie. the same revision as HEAD).

Edd
  • 3,724
  • 3
  • 26
  • 33
  • 1
    I'm not sure that you're 100% correct regarding the precondition that the working copy is updated before committing. Technically, I think you /can/ commit without updating first. However, I guess it is /not/ recommended and should be practiced with great care. Furthermore, I don't know when one would like to commit without first updating. – Dror Sep 29 '12 at 13:37
  • @Dror Yes you are right! It is best practice to update before committing, although sometimes subversion does not commit without update, it gives pop up error to update before committing. – Hamza Saeed Mar 17 '20 at 05:07
12

Update will update your checked out version to the latest version (or a specified other revision) in repository. If you have made changes to your working copy, they will still be there after the update. If files have been added or deleted to the repository, that will be reflected in your working copy. If there are changes both in your local copy and in the repository SVN will try to merge all changes for you, if that doesn't work it'll flag for a conflict that you resolve manually.

Svante Svenson
  • 12,315
  • 4
  • 41
  • 45
  • Sure you can update to the latest. This is what svn update does if you specify HEAD as the revision, or if you do not specify a revision at all. – Mike Miller Feb 12 '10 at 20:23
3

Subversion uses hidden directories of metadata to enable the functionality it provides. These .svn directories are what makes a directory into a Subversion working copy -- without these, it's just a directory and Subversion can't do much with it.

UPDATE is an operation that is performed over a Subversion working copy; no .svn directories, no UPDATE. CHECKOUT is the operation that creates a working copy.

Eric Kolb
  • 996
  • 6
  • 9
2

svn update brings only the difference in files from the user version to the latest available version. If no difference no actions.

But checkout creates a new folder and brings all the files for that branch. Checkout is a good way to work if we constantly change branches we work on. Update is when we have a trunk and need to get the updates done by others on that trunk.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
George
  • 21
  • 1
1

During using the SVN, the significant difference between checkout and update is that: You can only use the checkout command once to build up the relation between a local directory and the repository (under version control) and to copy all the files from the root repository to a local working directory. After that, using checkout to update the copies in local directory will generate errors as follows:

svn: E175002: Unable to connect to a repository at URL 'https://********'.

svn: E175002: The OPTIONS request returned invalid XML in the response:****."

The only way to update current versions in the local directory is to use the svn update command.

Z. Zhang
  • 209
  • 2
  • 4
  • 1
    what svn version did you see this behavior? I just did a "re-checkout" and it looks like it just interpreted it as an update. I'm running `svn, version 1.8.9 (r1591380)` – jxramos Oct 13 '17 at 00:13