Tried to see few dozen posts and still not getting what I want.
Preface: 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 Live and did a fix for production and deployed it. I then merged this fix into my trunk with no issues. We kept on working on trunk and also kept on deploying, but due to unnecessary complexities of SVN didn't merge trunk to Live even though we had few deployments. (This is all in SVN)
Migration: 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:
The problem is the branches are disconnected (no joining node) :-(
Please see image below:
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:
The process may impact negative, so I'm cautious.
Update: 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...
Possibility #1 - fix the structure
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 find that spot 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.
However, 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...
Possibility #2 - just rebase
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.