Erogol Erogol - 7 months ago 51
Git Question

How to use Bitbucket and GitHub at the same time for one project?

I have one repository which I want to push into Bitbucket and GitHub.
It is vital for my repository to be hosted by both.

Is there a way to do this in Git?


You can use multiple remote repositories with git. Check this:

But you'll have to push separately into 2 of your remotes I believe.

For example, if your project currently points to github, you can rename your current remote repository to github:

$ git remote rename origin github

You can then add another remote repository, say bitbucket:

$ git remote add bitbucket

Now in order to push changes to corresponding branch on github or bitbucket you can do this:

$ git push github HEAD
$ git push bitbucket HEAD

Same rule applies to pulling: you need to specify which remote you want to pull from:

$ git pull github your_branch
$ git pull bitbucket your_branch