简体   繁体   中英

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 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM