0

I have converted a repository from svn to git which had a customised structure in svn and I have to extract branches from the trunk's directory structure. Migrated git branches are:

branch: origin/branch_0.1.0
    contents: file_A
    change: created file_A

branch: origin/branch_0.2.0
    contents: file_B
    change: removed file_A, created file_B

branch: origin/branch_0.3.0
    contents: file_B
    change: edited file_B

here you can note that I do not have a master branch which I create in post process by merging all the above extracted branches in order with merge command as git merge -X theirs --allow-unrelated-histories origin/<branch> and if there are unmerged files then additionally run git add -A && git commit -m "<msg>". Issue I have is that the final master branch end up having both files file_A and file_B but the expected result should be only file_B as it was the only file present in last merged branch(branch_0.3.0).

I have also tried removing all the files (git rm -r .) before I do the procedural merge of branches but then I encounter an issue where file_B does not exists (while performing the merge for branch_0.3.0) but edited in HEAD/ other branches.

Could some one give me some pointers to fix this issue and also let me know if more information is required.

Cheers, DD.

DDStackoverflow
  • 505
  • 1
  • 11
  • 26
  • What `--allow-unrelated-histories` does is treat a merge that has no merge base commit as having the [empty tree](https://stackoverflow.com/q/9765453/1256452) as its merge base. This just means that all files in both of the to-be-merged commits are new. See other SO postings where I explain how `git merge` normally works. – torek Sep 02 '20 at 21:14
  • Can you post a view of the history of your commits ? `git log --graph --oneline origin/branch_0.1.0 origin/branch_0.2.0 origin/branch_0.3.0` – LeGEC Sep 03 '20 at 07:17

1 Answers1

0

If the three branches you created are one behind the other, e.g :

  • if origin/branch_0.2.0 is based on origin/branch_0.1.0
  • and origin/branch_0.3.0 is based on origin/branch_0.3.0

the starting point for your master branch is simply origin/branch_0.3.0 :

git branch master origin/branch_0.3.0
git checkout master
LeGEC
  • 46,477
  • 5
  • 57
  • 104