Git - Pull/Push with different repositories

Asked

Viewed 167 times

3

I have a project that sends to 2 repositories at the same time using the same remote, example:

[remote "origin"]
url = https://gitlab.com/teste.git
url = http://bitbucket.org/teste.git

In this type of situation, when I want to pull the project, it will use which of the 2 links as the basis ?

Would have some way to define which link I want to use when pulling ?

I believe he does not pull from the 2 repositories at the same time, because if there was a difference between them would be pointed out some error or something like.

  • 1

    the two branchs have the same name? why can you specify the name this way: git push origin [name-branch]

  • Yes, with the same name, but my doubt is at pull time, which of the Urls will Git pull.

  • If I’m not mistaken, if you spin git remote -v, it shows one of the Urls as fetch - That’s how he’ll do the pull.

1 answer

2


With this scenario you will have a problem, since the repositories that are in origin may have different commits.

One configuration that could be attempted would be to have 3 Origins, or better 3 remotes, one with the two URL’s and other 2 remotes, each configured with 1 URL’s. This way you could send to 2 repositories, but to receive you could use one remote first and then the other, making your repository the merge centralizer.

Maintaining a scenario this way is unnecessary if the goal is backup. The two URL’s used as an example at least have great backup services. If the idea is to have service redundancy in case of failure, there are other ways to synchronize the Repos, which would be the simplest solution, but outside the scope of this question.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.