3

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

and

$ git branch -r
  version-2.3.1
  version-2.3.2
  version-2.3.3
  trunk

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
etc

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.

Community
  • 1
  • 1
Eddified
  • 3,085
  • 8
  • 36
  • 47

1 Answers1

2

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.

lijinma
  • 2,914
  • 1
  • 23
  • 22
  • Do local branches get deleted when I "svn switch"? – Eddified Oct 10 '12 at 07: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 07:07
  • If you commit all uncommit items, you will not get deleted local branches. – lijinma Oct 10 '12 at 07: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 07:15
  • does `git svn fetch` only work on the current branch? Or does it update all of the remotes? – Eddified Oct 10 '12 at 07:15
  • Oh, looks like fetch only works on the "remote we are tracking" – Eddified Oct 10 '12 at 07:16
  • Yes... fetch only update the remotes...it does not work the current branch – lijinma Oct 10 '12 at 07:19
  • I think in the git-svn manual, it when it says "remote we are tracking" under "fetch", it's talking about the svn remote specified in the .git/config file, so I guess it's fetching all branches. – Eddified Oct 10 '12 at 07:19
  • Yes, you r right, for example, a remote is called 'Jinma', git fetch Jinma, it will fetch all branches of Jinma. – lijinma Oct 10 '12 at 07:23