Two GIT Projects

2

If I have a project already being done in git and at any given moment I need to join with another project but keep the history of commit how?

    
asked by anonymous 21.09.2017 / 21:18

1 answer

3
  

That was a necessity at work, had to put together some repositories. I have tailored what is in this answer , to be able to remedy my problem. Thanks to AP for discovering the original link I had lost

Know that you will need a lot of discipline for this.

I'll talk about my experience by putting together 3 repositories in a new one, okay?

First step was to create the new repository to aggregate the others. I started this repository with an initial commit (from README.md same) to have a starting point. I created a new branch named raiz with this commit (I do not change it, though).

So I added the desired remote repositories:

git remote add repo_old1 https://url/to/repo1
git remote add repo_old2 https://url/to/repo2

So I did the following:

git checkout raiz -b master
git merge repo_old1/master
mkdir repo1_dir
git mv {arquivos do repo1} repo1_dir/
git commit -m 'Sandboxando o repo1'

git merge repo_old2/master
mkdir repo2_dir
git mv {arquivos do repo2} repo2_dir/
git commit -m 'Sandboxando o repo2'

Next, you need to do the same for the develop; in the case, I started going to the branch raiz and doing the same operation:

git checkout raiz -b develop
git merge repo_old1/develop
mkdir repo1_dir
git mv {arquivos do repo1} repo1_dir/
git commit -m 'Sandboxando o repo1'

git merge repo_old2/develop
mkdir repo2_dir
git mv {arquivos do repo2} repo2_dir/
git commit -m 'Sandboxando o repo2'

So, we just needed to give push :

git checkout master && git push -u origin master
git checkout develop && git push -u origin develop

The step of isolating the repositories into separate folders was my strategy, since the focus of the initial repositories was different. One was TotalCross, another GWT, and the third was the common dependency between the two.

    
21.09.2017 / 21:35