git 如何为Bitbucket制作GitHub镜像?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21551929/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 09:41:13  来源:igfitidea点击:

How to make a GitHub mirror to Bitbucket?

gitgithubbitbucket

提问by Matrosov Alexander

I have a repo that I've cloned from GitHub and want to have a mirror of this repo on BitBucket. Is there is any way how to do it? Something like having two origin in the repo as I think.

我有一个从 GitHub 克隆的存储库,并希望在 BitBucket 上拥有此存储库的镜像。有什么办法可以做到吗?就像我认为的那样,在回购中有两个来源。

回答by VonC

You could simply add a second remote:

您可以简单地添加第二个遥控器:

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

and push everything to bitbucket:

并将所有内容推送到 bitbucket:

git push --mirror bitbucket

You can actually pull from or push to multiple remotesfrom your local repo.

您实际上可以从本地存储库中拉取或推送到多个遥控器



Update 2020:

2020 年更新:

As noted below in Rahulmohan Kolakandy's answer, if you are talking about an on-premise BitBucket server (as opposed to bitbucket.org), then you can take advantage of BitBucket Server Smart Mirroring.

正如下面Rahulmohan Kolakandy回答所述,如果您谈论的是内部部署的 BitBucket 服务器(而不是 bitbucket.org),那么您可以利用BitBucket Server Smart Mirroring

As commentedby V-Q-A NGUYEN:

正如VQA NGUYEN评论的那样:

BitBucket Server Smart Mirroring(introduced originally in 2016, and Oct. 2017 for BitBucket Server)

BitBucket Server 智能镜像最初于 2016 年推出2017 年 10 月为 BitBucket Server 推出

is only available for customers with an active Bitbucket Data Center license

仅适用于具有有效 Bitbucket 数据中心许可证的客户

回答by MoOx

The method explained here is better https://stackoverflow.com/a/12795747/988941

这里解释的方法更好https://stackoverflow.com/a/12795747/988941

git remote set-url origin --add https://bitbucket.org/YOU/YOUR_REPO.git

git remote set-url origin --add https://bitbucket.org/YOU/YOUR_REPO.git

Recent version of git handle multiple URLs in the same origin ;)

最新版本的 git 处理同一来源的多个 URL ;)

回答by RahulMohan Kolakandy

you no longer have to create these mirror links. Bitbucket has come up with this concept of smart mirror which does a real time sync to your mirror server.

您不再需要创建这些镜像链接。Bitbucket 提出了智能镜像的概念,它可以实时同步到您的镜像服务器。

More read here https://confluence.atlassian.com/bitbucketserver/smart-mirroring-776640046.html

在这里阅读更多 https://confluence.atlassian.com/bitbucketserver/smart-mirroring-776640046.html

Hope this helps!

希望这可以帮助!

回答by ?devrimbaris

You can also check the following (copy pasted from links below) ;

您还可以检查以下内容(从下面的链接复制粘贴);

From How to properly mirror a git repository, you can use

如何正确镜像 git 存储库,您可以使用

git clone --mirror [email protected]/upstream-repository.git

cd upstream-repository.git

git push --mirror [email protected]/new-location.git

Or you can follow Duplicating a repository;

或者您可以按照 复制存储库进行操作

Open Terminal and create a bare clone of the repository.

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

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

Mirror-push to the new repository.

镜像推送到新的存储库。

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

Remove the temporary local repository you created in step 1.

删除您在步骤 1 中创建的临时本地存储库。

cd ..
rm -rf old-repository.git