tags:

views:

1453

answers:

2

Duplicate

How do I make git-svn use a particular svn branch as the remote repository?

I am using git-svn to track development by someone else on svn. I'm trying to figure out how to use gti-svn to switch from one svn branch to another. All the examples I have able to find talk about using svn switch as method to switch location instead of actual branches.

Essentially, I would like to start pulling from /svn/branch/1.3 instead of /svn/branch/1.2 using svn fetch.

+1  A: 

If you've cloned the SVN repository properly (using -T -b -t or -s), you should be able to use the git branch commands like:

git reset --hard remotes/branch

git checkout branch

etc.

Can Berk Güder
What if I already have changes in my local repo that I push to a separate git repo on github? I created the repo originally using git svn clone http://svn/branch/1.2
Jauder Ho
git checkout branch doesn't destroy your changes. git reset --hard does.
Can Berk Güder
If you use reset --hard here, you'll blow away any changes made locally on top of remotes/branch.
rq
I do not own the svn repo and apparently only the branches are exposed (as releases). So this is not really a duplicate of the other request. In this scenario, I am not able to do a git branch -r followed by git checkout -b
Jauder Ho
Basically, git branch -r does not show the 1.3 branch just stuff under the 1.2.
Jauder Ho
How is the SVN repo structured?
Can Berk Güder
It's this. http://www.magentocommerce.com/svn
Jauder Ho
Now that's a weird one. A repo like this normally calls for git svn clone http://svn.magentocommerce.com/source -b branches, but http://svn.magentocommerce.com/source returns HTTP 403, so that probably won't work.
Can Berk Güder
That's my point, they have a strange setup and I've been trying to figure how to work around it.
Jauder Ho
+3  A: 

These commands have been incredibly useful for me when working on svn branches via git-svn:

#create local Git branch that mirrors remote svn branch

git checkout -b local/RELEASE-0.12 RELEASE-0.12 
#will connect with a remote svn branch named ‘RELEASE-0.12′

# -n will show which svn branch you will commit into:
git svn dcommit –dry-run

See full explanation in my article on justaddwater.dk: www.justaddwater.dk/2009/03/09/using-git-for-svn-repositories-workflow/

Jesper Rønn-Jensen