我有一个从GitHub克隆的仓库,想在BitBucket上拥有该仓库的镜像。有没有办法做到这一点?就像同时拥有两个源(origin)一样。
你可以简单地添加第二个远程:
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 许可证的客户
git remote set-url origin --add https://bitbucket.org/YOU/YOUR_REPO.git
使用Bitbucket Server,您可以使用ScriptRunner https://marketplace.atlassian.com/apps/1213250/scriptrunner-for-bitbucket-server-stash?hosting=server&tab=overview
完全披露:我为他们工作 :)
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