Search code examples
gitsvngit-svn

git - restore deleted svn branch without rereading svn history


I've accidentaly removed svn branch from my local git repo. Branch is still on the server, and I still have git branch which was tracking this svn branch.

I'd like to restore this branch where it was. If I do something like this git starts fetching this branch as a new, independent branch with no common ancestor and duplicated history entries. That's what I was afraid of.

Is there any way I could tell git to create svn branch at given commit-ish so it's history will be integrated with what I already have?


Solution

  • I handled this situation by myself:

    1. At .git\svn\refs\remotes\svn\ there was a 'copy' of deleted branch with @ in name. Something like this: .git\svn\refs\remotes\svn\branch@248166. I made a copy of this directory with @248166 removed.
    2. I've created file .git\refs\remotes\svn\branch with commit-ish taken from my tracking branch.
    3. I've launched git svn fetch -r 633500:HEAD where 633500 is svn revision for one svn commit before.

    And it worked.