如何在一个项目中同时使用Bitbucket和GitHub? [英] How to use Bitbucket and GitHub at the same time for one project?

查看:193
本文介绍了如何在一个项目中同时使用Bitbucket和GitHub?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个存储库,我想将其推送到Bitbucket和GitHub中. 这对于同时托管我的存储库至关重要.

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

在Git中有办法做到这一点吗?

Is there a way to do this in Git?

推荐答案

您可以将多个远程存储库与git一起使用.但是我相信您必须分别推入两个遥控器.

You can use multiple remote repositories with git. But you'll have to push separately into 2 of your remotes I believe.

例如,如果您的项目当前指向github,则可以将当前的远程存储库重命名为github:

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

$ git remote rename origin github

然后您可以添加另一个远程存储库,例如bitbucket:

You can then add another remote repository, say bitbucket:

$ git remote add bitbucket git@bitbucket.org:your_user/your_repo.git

现在,为了将更改推送到github或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

这篇关于如何在一个项目中同时使用Bitbucket和GitHub?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆