I've used the basic functionalities of SVN before to check in code and check it out. I've never touched branches and more complex stuff like that. Is it possible to use SVN so I can keep a master version of a source code file, make a slightly different version of it for a different project, and then have any changes to the master version be copied to the other versions without overwriting the changes made to those other versions?

I kind of doubt this is possible to easily deal with without having to manually deal with conflicts, so let me ask an alternative question: If I made a repository with a sort of common library of code and then made any project specific changes to that in separate files using class inheritance, is it possible to set it up so there are two repositories checked out in the same folder?


This is a difficult thing to do in SVN. It requires a lot of manual merging and is prone to errors. However, if you have the option, like @Ash mentions, distributed version control systems handle this scenario quite well. In particular, I know that Git makes this extremely easy.

The git-rebase command does exactly what you want. Assuming you have a main or "origin" branch of your source, you just make a new branch ("mywork") to make your project specific changes on(represented by block C6).

Project branch

Now, as the main branch of the code continues to change (revision C3 & C4), you just rebase your project specific branch to the new revision and you will get all of the changes that have been made on the main branch in you project's branch.

Rebase graph

There is still a possibility of having to do a manual merge, but the likelyhood of having to do it is much lower. Git takes a lot of the pain out of performing the merge operation. Check out the Git Book's rebasing chapter for more info.

  • I decided to install Git following this guide: scie.nti.st/2007/11/14/…. When I try to connect with Git Extensions though, it says FATAL ERROR: Network error: Connection timed out probably because my SSH runs on a non-standard port. It says how to change the port for linux, but I'm not sure how to do this on windows. – Telanor Sep 25 '10 at 4:10
  • When you go to clone a repo, put the port in the URI.. something like: git://user@example.com:2222/myrepo.git – heavyd Sep 25 '10 at 5:06
  • When I do that, it says it finished but shows a red X icon and the directory I told it to check out to doesn't exist – Telanor Sep 25 '10 at 5:33

I think this is pretty difficult to do with subversion (at least current versions), if not impossible, but a distributed version control system will handle it. I've used Mercurial to solve this problem:

On the "server" side:

  • Create a "master" repository
  • Clone that repository to make the project specific version of the repository (cloning is making a duplicate of an entire repository somewhere else)

On the "client" side:

  • Clone the project repository to your development area and check it out
  • Make changes, comitting locally a lot and pushing back to the server as appropriate

If changes to the master occur, they can be "pulled" into the project specific repository, which will flow down to the local repository. If changes made to the project specific repository are deemed suitable for the "master", they can be pushed back up to it. Mercurial remembers the paths between parent repositories, so it all fits together. Merges between branches (which you tend to use a lot more) and repositories are generally pain free. One disadvantage is that Mercurial doesn't allow "cherry picking" of updates, but that can be an advantage since it keeps you out of potential trouble in future merges.

There's probably a bigger a learning curve in doing all this, but might be worthwhile to investigate.


The short answer is "no". The problem you describe is merging the branches when there's a change. There are tools that will assist but in the end you're merging two branches of code that have both changed. This situation may cause a conflict which will require human intervention.


Isn't this question much better asked over on SO (which has over 5,000 SVN questions)? I see there are some SVN questions here, but I don't know what makes one better suited for either site.

  • 1
    This isn't an answer. It should have been posted as a comment. – Dennis Williamson Sep 24 '10 at 2:23
  • @DennisW Yeah, sorry, I couldn't post comments at the time. – Mark C Oct 12 '10 at 23:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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