GIT with multiple remotes in one project

1

I have project A which is my main project. From this project was born project B, for "fork". Wonder, so I want to develop things in Project A and I want to replicate them to Project B. When I develop things in project A and commit push and everything beauty, then I go to project B which I cloned and added a new remote to it:

git remote add upstream url_projeto

I do:

git merge upstream/master

Wonder, come changes, BUT some things are not coming. I do not know why, for example a folder with their respective files did not come.

And also against start, I have developed things in Project B that do not exist in his father's "Project A" and when I do a merge in Project B with Project A he goes and deletes some things even though they never existed in project A.

Is it clear what the problem is?

    
asked by anonymous 06.07.2017 / 00:16

1 answer

3

I think it's not so interesting to work on two two projects on two remotes. (And if I understood the case, the A project has only 1 remote, while the B project has both.) It is possible to use only 1 repository with 2 remotes, but will require some care.

When the git remote add upstream url_projeto code is executed, git creates an internal reference for another repository (in addition to what already came in the clone), so it is possible to have "n" references. Example:

Adding remote with reference to github:

git remote add github https://github.com/userx/repox.git

Adding remote with reference to bitbucket:

git remote add bitbucket https://[email protected]:1234/repox/repo.git

Adding remote with reference to gitlab:

git remote add gitlab http://gitlab.com/usex/repox.git

As you can see, in the above example I created 3 remotes for the same project ( gitub , bitbucket , gitlab ), I can work with all 3 at the same time.

Assuming that more than one person has permission only in github, while another who works on gitlab needs these modifications, but you as a system intermediary need to resolve the situation.

git fetch github master
git pull github
git push gitlab master
# Note que o remote sempre é especificado

Okay, now gitlab has been updated with the github content. But even so it is still very complicated to manage these changes in this way ... I recommend that you try to work with only one remote, because it is possible that many problems occur, for example conflicts in which only the administrator can solve them.     

06.07.2017 / 00:51