Chris
Chris

Reputation: 1731

Can I / How Do I Branch a Specific Directory

I want to create a branch of a specific directory inside my code base. I don't want to create a whole new copy of the repository.

Can I create a branch of a single directory (with all it's subfolders) without copying the whole repository?

Upvotes: 0

Views: 73

Answers (1)

David W.
David W.

Reputation: 107040

When you branch via svn cp, you're not duplicating anything. Instead, all you're doing is creating a pointer to a branch point.

You can make a branch of your directory (and all subdirectories), but I highly recommend you create a branch of the entire project:

$ svn cp --parents $REPO/trunk/project  $REPO/branches/4.2/project

This doesn't take up any more room in the repository and will execute instantly. Before I'm branching the whole project, I can checkout the project from the branch, and be able to build my project on the branch. I could just branch the particular directory:

$ svn cp --parents $REPO/trunk/project/subdir $REPO/branches/4.2/subdir

But that makes it impossible to build your branch since it doesn't contain the whole project.

The advantage with using svn cp is that it allows Subversion to do merges since Subversion knows where the branch came from:

$ svn co $REPO/trunk/project
$ cd project/subdir
$ svn merge $REPO/branches/4.2/project/subdir

This will all of the changes you've made on your branch back to the trunk.

NOTE: I am assuming you are using a Subversion 1.8 client. Otherwise, you get into the whole reintegrate vs. merge issue.

Upvotes: 1

Related Questions