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. But you'll have to push separately into 2 of your remotes I believe. Show activity on this post.
Yes it is. You tell git where the remote code lives from a per-repository configuration file. You can even push to GitHub and Bitbucket from the same repository if you want to. One important piece will be connecting to each separately with SSH.
To push to a Git repository At the command line, make sure you've changed into the repository directory. Enter git push at the command line to push your commits from your local repository to Bitbucket. To be specific about exactly where you're pushing, enter git push <remote_server> <branch_name>.
You can use multiple remote repositories with git. 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 [email protected]:your_user/your_repo.git
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
Yes, you can do that. You don't have to push twice but just once to push to both remote repositories. I had the same issue before so wrote how to do it here. Git: Push to / Pull from Both Github and Bitbucket
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With