0

I have two git repositories -

  • One - with directory structure src/com/yadavvi/stringsearch
  • Two - with directory structure src/com/yadavvi/prettyprint, src/com/yadavvi/tree, src/com/yadavvi/treewoq.

I want to merge both these repositories into a single repository One, such that the final directory structure of the resulting repo would be -

src/com/yadavvi/stringsearch
src/com/yadavvi/prettyprint
src/com/yadavvi/tree
src/com/yadavvi/treewoq

However, I get to see only src/com/yadavvi/stringsearch and others are visible ONLY in the commit history.

I followed this, this and this tutorials for merging two repos, but the output that I get is somewhat like this -

History as shown in gitk

Here is my GitHub repository when I pushed it.

yadav_vi
  • 1,289
  • 4
  • 16
  • 46
  • What don't you like about the resulting merged repository? At first glance the output seems just what you would want. – antlersoft Jan 21 '15 at 18:26
  • @antlersoft I only see `src/com/yadavvi/stringsearch` not the others like ` src/com/yadavvi/prettyprint` etc. – yadav_vi Jan 21 '15 at 18:30

3 Answers3

1

Your merge commit deleted everything that was not under stringsearch. You need to reset to a commit before the merge and try again. Use --no-commit on the merge command and make sure the index contains all the files from the other branch before you commit the merge.

antlersoft
  • 14,636
  • 4
  • 35
  • 55
  • I did a hard reset as mentioned [here] (http://stackoverflow.com/a/4372501) and got the original repository. Then again I followed the same procedures given [here] (https://help.github.com/articles/about-git-subtree-merges/) with `git merge -s ours --no-commit PrettyPrintTree/master` and then with `git read-tree --prefix=/ -u PrettyPrintTree/master` and it seem to work. – yadav_vi Jan 21 '15 at 19:47
0

For such a scenario one might want to give git-import a try.

It basically creates patches from one repo and applies them to another while keeping history.

ViToni
  • 882
  • 9
  • 12
0

first check branch with using git branch then change branch whrere you want to merge branch chekout <branch name> then merge with existing branch branch merge <branch name>

it will work