1

I have searched and tried multiple solutions from past 2 days and nothing seems to be working out for me.

I currently have the following directory structure which is opencart framework

[git repo 1]
  -admin
  -image
  -CB [git repo 2]
    -catalog 
  -system
  -vqmod

I need to merge repo 2 into repo 1 and move the catalog folder back into the original flat folder structure and track it as single repo, with all the history from repo 2 and merging also because I need to setup git-flow on azure in coming days.

So the final structure should be in single repo:

[git repo1]
  -admin
  -image
  -catalog
  -system
  -vqmod

In the initial phase i made a mistake of thinking there was no need to include other folders except for catalog, but now there is a requirement to work with entire opencart framework modules.

SOLUTIONS TRIED:

solution 1 => as suggested in comments here, subtree is not the solution i am looking for because i want to remove repo 2 from the scene and manage only 1 repo (repo 1).

solution 2

solution 3 => closest solution that i could find, but it did not work as it still keeps the files inside subdirectory CB/

There may be similar questions but nothing that worked out, if there are some answers i have missed please point me to the right direction.

Help would be greatly appreciated

Zameer Fouzan
  • 666
  • 6
  • 15
  • 1
    More reading: [blog](https://saintgimp.org/2013/01/22/merging-two-git-repositories-into-one-repository-without-losing-file-history/) / [another question](https://stackoverflow.com/questions/1425892/how-do-you-merge-two-git-repositories) – cole Jul 01 '17 at 20:17
  • I believe with the provided solutions of merging two repos to one, you just need one extra commit to do the folder layout. You have to have a project folder (root of .git, like `CB`), but you can use one extra commit to smooth the folder structure. Let me know if this is possible. – chenrui Jul 01 '17 at 22:27
  • @C.Arendt thanks , let me try. – Zameer Fouzan Jul 02 '17 at 08:21
  • @chenrui i did not really understand the part of "one extra commit" , an extra commit is fine for me but what and how that commit should be? – Zameer Fouzan Jul 02 '17 at 08:22
  • I presume something like `git mv ./CB/* ./`. A commit that moves your files into the current directory. I don't think removing the directory should be necessary at that point, but may be something you need with `git rm` – cole Jul 02 '17 at 10:10
  • @C.Arendt yes, you just need git mv the folder, and then the folder layout will meet your needs. – chenrui Jul 02 '17 at 11:02
  • 1
    @Zammer I tried the solution 3, actually, there is just one merge commit (merge remote branch commit) from repo2 to repo1, is that what you really want? – chenrui Jul 02 '17 at 11:14
  • @C.Arendt the first you suggested "blog" worked for me with some cut down and tweaks, same as said by chenrui – Zameer Fouzan Jul 04 '17 at 03:24
  • @chenrui yes, you were right thats exactly what i came up with after looking at the link given by C.Arendt . Thank you – Zameer Fouzan Jul 04 '17 at 03:26

0 Answers0