Reputation: 61
Our project's trunk looks something like:
trunk/foo
trunk/bar
trunk/baz
The subdirectories foo, bar, and baz are actually unrelated to each other, and bar and baz are actually quite huge. How do I create a branch with just foo, such that my branches would look something like:
branches/branch1/foo
branches/branch2/foo
Right now, what I'm doing is branching the whole trunk, then deleting bar and baz, but I think that would be problematic during the merge since it would try to delete bar and baz. What I'd like is for it to be intelligent enough to know that I just want to work with foo and not do anything with bar or baz.
Secondary question, not as important, what if I want a branch with foo and bar, like:
branches/branch1/foo
branches/branch1/bar
Would the process for branching these two folders without branching the others be harder?
Edit: It's been pointed out to me that I can use svn cp. This works, but I was hoping to work from a git svn repo, and as far as I can tell, the closest analogue git-svn has to svn cp is git svn branch, which automatically handles the copying. Unfortunately, I can't find any option in there that lets me branch just a specific subdirectory.
Upvotes: 4
Views: 815
Reputation: 3577
not sure the exact syntax for this, nor do i know if this will work, but I think you could try to make the three different folders git submodules.
can you point the git clones to each trunk individually and clone them that way?
Upvotes: 0
Reputation: 414855
It is common that one giant svn repository is represented by many git repositories. You should have used git svn init .. -t trunk/foo -b branches/branch1/foo -b branches/branch1/foo
etc. Note: init
, not clone
. Then edit .git/config
:
[svn-remote "foo"]
url = http://server.org/svn
fetch = trunk/foo:refs/remotes/foo/trunk
branches = branches/*/foo:refs/remotes/foo/branches/*
tags = tags/*/foo:refs/remotes/foo/tags/*
Then do git svn fetch
. In addition you could specify --ignore-paths
e.g., to ignore docs
directory.
After that git svn branch
should do the right thing. See git-svn manual
.
Upvotes: 4
Reputation: 2781
svn copy will happily operate at any level in the folder structure.
Just do:
svn cp trunk/foo branches/branch1/foo
Think of it like a typical unix filesystem.
You might have to add --parents to the cp line if branch1 doesn't exist yet.
Upvotes: 2
Reputation: 994649
Branching in Subversion is basically just making copies of files (but they aren't really copies since they don't take up any space). So:
svn cp svn://server/repo/trunk/foo svn://server/repo/branches/branch1/foo
You don't need to copy the bar
and baz
directories if you don't want to. Alternately, you can copy everything (since copy is essentially free) and check out only what you need:
svn cp svn://server/repo/trunk svn://server/repo/branches/branch1
svn co svn://server/repo/branches/branch1/foo
Upvotes: 0