Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

One of the advantages of SVN over CVS as given here is cheap copying and branching. What does "cheap copying and branching" mean in SVN parlance? How is it different from CVS copying and branching?

share|improve this question
Note that this "cheap" copy is not really cheap - it seems to copy references to all files or whatever, but unlike in git it takes some non-negligible time. But this is all unimportant, merging is where the problems start. –  maaartinus Sep 4 '12 at 16:19
add comment

3 Answers

up vote 3 down vote accepted

If I read it right "cheap copying and branching" is the same as "lazy copying and branching".

In these schemes the file isn't actually copied until it becomes different from the parent file. The system creates a placeholder for the file but when you read the contents it goes back to the main trunk for the contents.

This has the main advantage of saving disk space on your server. If you did a full copy of the trunk then you would double the amount of disk space you need on your server. By only actually copying the files that have changed you drastically reduce this requirement. A typical branch will only actually modify a handful or a few hundred files at most.

Another significant advantage is that as the files aren't copied until needed the creation of the branch is a very quick operation. This encourages branching as it's now seen as a cheap/quick operation rather than an expensive/slow one. (Thanks to Andres F. and Murph for pointing that out)

share|improve this answer
Isn't it similar in CVS? (by "it", I mean the fact that the file is copied only it is different from the parent one) –  MainMa Sep 4 '12 at 15:01
@MainMa - I don't know the details of CVS to comment on that. I was primarily answering the "what does it mean" aspect of the question. –  ChrisF Sep 4 '12 at 15:02
@MainMa CVS copies files when branching or tagging, which makes it an "expensive" operation both in terms of the time it takes to create the branch/tag, and the disk space it takes up. –  Andres F. Sep 4 '12 at 15:15
@Andres F., ChrisF: thank you for the info. –  MainMa Sep 4 '12 at 15:16
There are two advantages - the other Very significant one is speed, as there's no physical copying of files 'til required and hence a branch (or tag) operation will take a minimal amount of time - which should help encourage branching as required. –  Murph Sep 4 '12 at 15:19
add comment

SVN "cheap copies and branches" is explained in the manual ( http://svnbook.red-bean.com/en/1.1/ch04s02.html ). Relevant section:

Cheap Copies

Subversion's repository has a special design. When you copy a directory, you don't need to worry about the repository growing huge—Subversion doesn't actually duplicate any data. Instead, it creates a new directory entry that points to an existing tree. If you're a Unix user, this is the same concept as a hard-link. From there, the copy is said to be “lazy”. That is, if you commit a change to one file within the copied directory, then only that file changes—the rest of the files continue to exist as links to the original files in the original directory.

This is why you'll often hear Subversion users talk about “cheap copies”. It doesn't matter how large the directory is—it takes a very tiny, constant amount of time to make a copy of it. In fact, this feature is the basis of how commits work in Subversion: each revision is a “cheap copy” of the previous revision, with a few items lazily changed within. (To read more about this, visit Subversion's website and read about the “bubble up” method in Subversion's design documents.)

Of course, these internal mechanics of copying and sharing data are hidden from the user, who simply sees copies of trees. The main point here is that copies are cheap, both in time and space. Make branches as often as you want.

Note that this isn't how CVS works. Copies in CVS are "expensive", both in the time it takes to create the branch, and the disk space it takes up.

share|improve this answer
add comment

What I understand for cheap process in terms of create a branch of a tag in SVN in when you execute the command(svn tag or branch), the command itselft ins't creating a new physical folders with the content of all your project, all the system do it's replicate the structure base of the snapshot of you trunk which is pretty different than copy and paste all the files in the new folder, bring the consequence that the application that the process it's faster.

share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.