开发者

How to recreate a git svn remote tracking branch?

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开发者_C百科 git svn reset, etc. to no avail.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜