首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Git将现有的repo推送到新的和不同的远程repo服务器?

Git将现有的repo推送到新的和不同的远程repo服务器?
EN

Stack Overflow用户
提问于 2011-03-03 22:13:07
回答 7查看 499.4K关注 0票数 589

假设我在git.fedorahosted.org上有一个存储库,我想把它克隆到我在github上的帐户中,这样除了在fedorahosted上更“官方”的repo之外,我还可以有自己的游乐场。最初复制它的步骤是什么?在github中有一个很好的"fork“按钮,但由于显而易见的原因,我不能使用它。

我如何将fedorahosted repo中的更改跟踪到github中?

EN

回答 7

Stack Overflow用户

发布于 2013-09-12 05:51:00

这个问题有一个已删除的答案,其中有一个有用的链接:https://help.github.com/articles/duplicating-a-repository

要点是

代码语言:javascript
复制
0. create the new empty repository (say, on github)
1. make a bare clone of the repository in some temporary location
2. change to the temporary location
3. perform a mirror-push to the new repository
4. change to another location and delete the temporary location

OP的例子:

在您的本地计算机上

代码语言:javascript
复制
$ cd $HOME
$ git clone --bare https://git.fedorahosted.org/the/path/to/my_repo.git
$ cd my_repo.git
$ git push --mirror https://github.com/my_username/my_repo.git
$ cd ..
$ rm -rf my_repo.git
票数 133
EN

Stack Overflow用户

发布于 2018-08-28 15:12:17

如果您有现有的Git存储库:

代码语言:javascript
复制
cd existing_repo
git remote rename origin old-origin
git remote add origin https://gitlab.com/newproject
git push -u origin --all
git push -u origin --tags
票数 21
EN

Stack Overflow用户

发布于 2015-08-19 08:03:20

您真的想简单地推送本地存储库(及其本地分支等)吗?到新的遥控器,或者你真的想在新的遥控器上镜像旧的遥控器(及其所有的分支,标签等)?如果是后者,在How to properly mirror a git repository上有一个很棒的博客。

我强烈建议你阅读博客,了解一些非常重要的细节,但简短的版本是这样的:

在新目录中运行以下命令:

代码语言:javascript
复制
git clone --mirror git@example.com/upstream-repository.git
cd upstream-repository.git
git push --mirror git@example.com/new-location.git
票数 18
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5181845

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档