Disconnected GIT branches after migrating from SVN


Tried to see few dozen posts and still not getting what I want.

<strong>Preface</strong>: We initially had a very big SVN repository with no trunk (standard structure) etc. So, the project I was working had no structure too (inside the sub-folder). I worked on this project for about couple of months and then came across a situation where I needed a branch for production fix. So, I restructured only my project code into trunk, tags and branches (i.e. sub-directory within the SVN repository). Then from history I created a branch named <em>Live</em> and did a fix for production and deployed it. I then merged this fix into my <em>trunk</em> with no issues. We kept on working on <em>trunk</em> and also kept on deploying, but due to unnecessary complexities of SVN didn't merge <em>trunk</em> to <em>Live</em> even though we had few deployments. (This is all in SVN)

<strong>Migration</strong>: We recently decided to setup a new TFS server and have our version control via GIT. So, after the installation was done, I had a task to migrate the code only for this project to GIT. I started doing it on my local PC using "git svn clone" and was happy to see all my history was migrated. Have branches as:

<ul><li><em>master</em>: originated from trunk and I can see the history from the time I had re-structured it in SVN.</li> <li><em>Live</em>: Goes back from the beginning of the SVN repository (project folder creation date) and marked as branch name properly.</li> </ul>

The problem is the branches are disconnected (no joining node) :-(

Please see image below:

<a href="https://i.stack.imgur.com/ON6rI.jpg" rel="nofollow"><img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/ON6rI.jpg" data-original="https://i.stack.imgur.com/ON6rI.jpg" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" /></a>

As per the above image, the master branch starts at the highlighted commit (node) but Live branch just starts from the SVN 1st commit.

Ideally I would have wanted to have everything on master and Live shown as branch from master when it was really created. Also, when I try to checkout Live branch, I get warning that it is detached HEAD and I may not get/push the commits to master (i.e. HEAD) branch.

Can someone send me the steps to fix this scenario, please?

Possible solution, I think:

<ul><li>Rename the <em>master</em> to <em>svn-trunk</em> and <em>Live</em> to <em>SVN-Live</em></li> <li>Then create a branch named <em>master</em> from <em>SVN-Live</em> (will it have any conflict at remote?) at the commit when I had done restructure (one before highlight i.e."Live 2656").</li> <li>Merge <em>SVN-trunk</em> on Master.</li> <li>Create new branch named <em>Live</em> from this HEAD (as currently the final code is in production).</li> </ul>

The process may impact negative, so I'm cautious.

<ul><li>My only worry is will it allow me to merge the commits from disconnected <em>SVN-trunk</em> to my new <em>master</em>? (Right now Git Extensions show me the option to merge Live to Master but not other way round.</li> <li>Also, if I do trial and error locally and screw up things, how should a reset back to current state?</li> </ul>

<strong>Update</strong>: Renamed the branches and Created master based on the "Live@2656". Now, trying to merge "Svn-trunk" to master (new branch) - I get below error:

fatal: refusing to merge unrelated histories Done


Maybe start form a fresh git svn clone as it may save some headache. Also it is not a bad idea to keep a copy of such acquired git repository somewhere safe :)

Still there are two ways you may try...

<strong>Possibility #1 - fix the structure</strong>

A cleaner way would be to reconstruct the real structure of the repository. If I understand correctly, trunk was created at some point in history. If you are able to <strong>find that spot</strong> in the history you may be able to use git rebase <SHA of that spot in branch Live> to reconnect the histories together. Some conflicts may appear, though.

<strong>However</strong>, if you have merged some development progress back to Live while on SVN you may have a hard time while merging. To circumvent this you may reconstruct these merges as proper merge commits but it may not be worth the time if you do not have to have a proper history...

<strong>Possibility #2 - just rebase</strong>

Or a much simpler solution if you do not care about the proper history at all...

git checkout master git rebase Live

The only thing you need to be certain about in there is the resolution of possible conflicts.


For a one-time migration git-svn is <strong>not</strong> the right tool for conversions of repositories or parts of repositories. It is a great tool if you want to use Git as frontend for an existing SVN server, but for one-time conversions you should <strong>not</strong> use git-svn, but svn2git which is much more suited for this use-case.

There are plenty tools called svn2git, the probably best one is the KDE one from <a href="https://github.com/svn-all-fast-export/svn2git" rel="nofollow">https://github.com/svn-all-fast-export/svn2git</a>. I strongly recommend using that svn2git tool. It is the best I know available out there and it is very flexible in what you can do with its rules files.

You will be easily able to configure svn2gits rule file to produce the result you want from your current SVN layout, including any complex histories like yours that might exist and including producing several Git repos out of one SVN repo or combining different SVN repos into one Git repo cleanly in one run if you like.

If you are not 100% about the history of your repository, svneverever from <a href="http://blog.hartwork.org/?p=763" rel="nofollow">http://blog.hartwork.org/?p=763</a> is a great tool to investigate the history of an SVN repository when migrating it to Git.

<hr />

Even though git-svn is easier to start with, here are some further reasons why using the KDE svn2git instead of git-svn is superior, besides its flexibility:

<ul><li>the history is rebuilt much better and cleaner by svn2git (if the correct one is used), this is especially the case for more complex histories with branches and merges and so on</li> <li>the tags are real tags and not branches in Git</li> <li>with git-svn the tags contain an extra empty commit which also makes them not part of the branches, so a normal fetch will not get them until you give --tags to the command as by default only tags pointing to fetched branches are fetched also. With the proper svn2git tags are where they belong</li> <li>if you changed layout in SVN you can easily configure this with svn2git, with git-svn you will loose history eventually</li> <li>with svn2git you can also split one SVN repository into multiple Git repositories easily</li> <li>or combine multiple SVN repositories in the same SVN root into one Git repository easily</li> <li>the conversion is a gazillion times faster with the correct svn2git than with git-svn</li> </ul>

You see, there are many reasons why git-svn is worse and the KDE svn2git is superior. :-)


  • Get a series of commits on a detached head onto a branch
  • Passing/giving commands to CMD through Qt GUI
  • What is the difference between getHibernateTemplate().update and getHibernateTemplate().merge
  • Tips on upgrading CVS to git/hg?
  • Git remove last commits from remote made by someone else
  • How can I see the entire SCM history in my Xcode project?
  • Track files but exclude them from a git bundle
  • Reset to the very first commit in Git?
  • Why does checkout sometimes stage a file?
  • Disable add to cart redirection
  • c# web browser click on a button with a class name
  • Is there any way to call saveCurrentTurnWithMatchData without sending a push notification?
  • Angular Bootstrap Carousel Slide Transition not working correctly
  • How to create two column output from a single column
  • How can I get the choice “H2” back in the H2 consol?
  • Tell Git to stop prompting me for conflicts when none really exist?
  • Approximate Order-Preserving Huffman Code
  • Silverlight DependencyProperty.SetCurrentValue Equivalent
  • How solve “Qt: Untested Windows version 10.0 detected!”
  • C: Incompatible pointer type initializing
  • Jquery UI tool tip close icon
  • Display issues when we change from one jquery mobile page to another in firefox
  • C# - Is there a limit to the size of an httpWebRequest stream?
  • Get object from AWS S3 as a stream
  • Finding past revisions of files in StarTeam w/ .NET SDK / C#
  • Java applet as stand-alone Windows application?
  • Updating server-side rendering client-side
  • MySQL WHERE-condition in procedure ignored
  • Adding custom controls to a full screen movie
  • Function pointer “assignment from incompatible pointer type” only when using vararg ellipsis
  • How to pass list parameters for each object using Spring MVC?
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • Comma separated Values
  • Error creating VM instance in Google Compute Engine
  • Why can't I rebase on to an ancestor of source changesets if on a different branch?
  • Hits per day in Google Big Query
  • how does django model after text[] in postgresql [duplicate]
  • sending mail using smtp is too slow
  • How to Embed XSL into XML
  • How to push additional view controllers onto NavigationController but keep the TabBar?