SVN: Possible to have changes propagate to different versions of a file

svnversion control

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?

Best Answer

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.

Related Question