Take the 2-minute tour ×

I have cloned my svn repo using git, specifying branches and trunk (no tags involved). Then, I ran fetch for a limited range of revisions. Now, I have:

$ git branch
* master


$ git branch -r

So, I understand that these branches are remote branches, and I did read http://git-scm.com/book/en/Git-Branching-Remote-Branches , but because remote branches are new to me, I'm having a hard time understanding how to use that knowledge in a svn context. One person at this link How to switch svn branches using git-svn? said to just do:

git reset --hard remotes/branch
git checkout branch

but the 2nd command, "git checkout branch" doesn't apply to me since I don't have any local branches.....

So, now that I've got a bunch of remote branches that correspond to svn branches, what is the recommended workflow for "svn switch"ing to one of the branches, dcommit'ing, then "svn switch"ing back to a different branch? I never use trunk, I'm always working on branches.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Now you are in master branch, you just:

git reset --hard version-2.3.3

and then your master branch is same as remote branch version-2.3.3.

Create another branch:

git checkout -b local-version-2.3.1
git reset --hard version-2.3.1

Then you create a new branch named: local-version-2.3.1, and it's the same as remote branch version-2.3.1.

Good luck.

share|improve this answer
Do local branches get deleted when I "svn switch"? –  Eddified Oct 10 '12 at 7:02
Once I've created a local branch corresponding to each remote branch, I won't ever have to run the git checkout -b local-version-X.Y.Z command again? –  Eddified Oct 10 '12 at 7:07
If you commit all uncommit items, you will not get deleted local branches. –  lijinma Oct 10 '12 at 7:11
Actually you don't understand what's remote branches, the remote branches mean some branches you clone from remote, but now the remote branches are also locally. you got my point? –  lijinma Oct 10 '12 at 7:15
does git svn fetch only work on the current branch? Or does it update all of the remotes? –  Eddified Oct 10 '12 at 7:15

Your Answer


