0

I have multiple projects that (Dynamics CRM solutions for those who knows) that have have the same folder structure and I need to merge one project with another in order to:

  • Merge files that have the same name.
  • Add files from one project to the other if not exists.

What would be the best way doing it with GIT ?

  • I have tried to create a single repository where I've uploaded project A. Then, I've created a branch from it where I've placed the project B. When I merge the branch project B into the branch project A, files from project A with the same name of project B are replaced by those from project B.
  • I have also tried the submodules concept but it isn't finally the right thing to do.
Hubert Solecki
  • 2,611
  • 5
  • 31
  • 63

1 Answers1

1

If you want to keep the history and the fact that they were merged, then:

git clone git@projecta
cd projecta
git remote add -f projectb git@projectb
git merge projectb/master

If you don't care about history - then just place files manually and commit. It's possible to make a merge commit (that points to 2 parents) even in case of manual merge with low-level commands like git-commit-tree.

Stanislav Bashkyrtsev
  • 14,470
  • 7
  • 42
  • 45
  • Thanks ! So it's two different GIT repositories and not branches ? – Hubert Solecki Nov 22 '17 at 15:14
  • Git doesn't care if it's 2 repos or 2 branches or no branches at all. Git works with graphs of commits; branches & remote branches are just pointers to those commits. For Git origin/master & projectb/master are 2 pointers of the same kind. You can explore the content of `.git/refs/remotes` to find them. – Stanislav Bashkyrtsev Nov 22 '17 at 15:26