如何将GitHub镜像到Bitbucket?

37

我有一个从GitHub克隆的仓库,想在BitBucket上拥有该仓库的镜像。有没有办法做到这一点?就像同时拥有两个源(origin)一样。

5个回答

52

你可以简单地添加第二个远程:

git remote add bitbucket /url/to/am/empty/bitbucket/repo

并将所有内容推送到Bitbucket:

git push --mirror bitbucket

你可以从本地存储库中实际上拉取或推送到多个远程存储库


2020年更新:

如下所述,在Rahulmohan Kolakandy答案中,如果你正在谈论企业 BitBucket 服务器(而不是 bitbucket.org),那么你可以利用BitBucket Server 智能镜像

V-Q-A NGUYEN评论中指出的:

BitBucket Server 智能镜像最初于2016年引入2017年10月用于 BitBucket Server

仅适用于拥有活动 Bitbucket Data Center 许可证的客户


BitBucket Server的智能镜像功能仅适用于持有活跃的Bitbucket Data Center许可证的客户。 - V-Q-A NGUYEN
@V-Q-ANGUYEN 谢谢,好观点。我已经将您的评论包含在答案中以增加可见性。 - VonC

9

4

3

好观点(+1)我已经在我的答案中包含了这个功能以获得更多的可见性。 - VonC

2
您可以查看以下内容(从下面的链接复制);
如何正确镜像一个git仓库,您可以使用
git clone --mirror git@example.com/upstream-repository.git

cd upstream-repository.git

git push --mirror git@example.com/new-location.git

或者您可以查看复制存储库的操作;

打开终端并创建存储库的裸克隆。

git clone --bare https://github.com/exampleuser/old-repository.git

将镜像推送到新仓库。

cd old-repository.git
git push --mirror https://github.com/exampleuser/new-repository.git

删除你在步骤1中创建的临时本地仓库。

cd ..
rm -rf old-repository.git

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接