2

I'm using git as an interface to an SVN repository. Now I've created a SVN branch:

git svn branch my_branch

This created the directory in my SVN repository, and also created a branch called remotes/my_branch. Then I've deleted that remote tracking branch:

git branch -r -d my_branch

Now the directory is still there in the SVN repository, but I can't seem to find a way to get the remote tracking branch back. Any idea? I tried

git svn branch my_branch
=> branch test_new_mod_named already exists

and played around with git svn reset, etc. to no avail.

Jonas Wagner
  • 358
  • 3
  • 10
  • One thing that worked was to delete the branch on SVN and recreate it using "git svn branch my_branch". But this can't be the best solution, can it? Cause it creates two useless commits in SVN. – Jonas Wagner Aug 27 '10 at 14:29
  • http://stackoverflow.com/questions/296975/how-do-i-tell-git-svn-about-a-remote-branch-created-after-i-fetched-the-repo might help. – Tyler Dec 09 '10 at 09:49

1 Answers1

0

The easiest way I found to be making a commit in my_branch using svn, and then doing another git svn fetch.

$ git svn branch my_branch
Copying file:///Users/tfnico/svn-repo/website/trunk at 
r14 to file:///Users/tfnico/svn-repo/website/branches/my_branch...

Remote branch is there:

$ git branch -a
  master
* trunk
  remotes/my_branch

Delete branch:

$ git branch -r -d my_branch
Deleted remote branch my_branch (was d422fbd).

And branch is gone. Now try a git svn fetch to recreate it:

$ git svn fetch

Nothing happens, until somebody does this...

$ svn checkout file:///Users/tfnico/svn-repo/website/branches/my_branch/

... and makes a commit. Voila:

$ git svn fetch
    M   hotfix.txt
r19 = f7449780fbb653cbcbc09861c0b446d41321e3f5 (refs/remotes/my_branch)
[17:29:33] tfnico:~/sources/git/website/[trunk]>git branch -a
  master
* trunk
  remotes/my_branch

Remote branch is back.

Thomas Ferris Nicolaisen
  • 5,036
  • 2
  • 30
  • 36