Git推现有的回购一个新的和不同的远程回购服务器?
假设我在git.fedorahosted.org上有一个存储库,我想在github上把它克隆到我的帐户上,除了fedorahosted上更“官方”的回购之外,还有我自己的游乐场。 最初复制的步骤是什么? 在github中有这个不错的“fork”button,但是我不能明显地使用它。
我将如何跟踪fedorahosted回购进入github的变化?
- 在github上创build一个新的回购。
- 从fedorahosted克隆到本地机器的回购。
- git remote rename origin upstream
-  git remote add origin URL_TO_GITHUB_REPO
-  git push origin master
 现在,您可以像使用其他github回购一样使用它。 要从上游获取补丁,只需运行git pull upstream master && git push origin master 。 
这个问题有一个有用的链接删除答案: https : //help.github.com/articles/duplicating-a-repository
要点是
 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的例子:
在你的本地机器上
 $ 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 
为了推动你现有的回购不同,你需要:
- 
首先克隆原始回购。 git clone https://git.fedorahosted.org/cgit/rhq/rhq.git
- 
将克隆的源码推送到您的新存储库: cd rhq git push https://github.com/user/example master:master
 您可以将master:master更改为source:destination分支。 
如果你想推特定的提交(分支),那么做:
- 
在原始的仓库中,创build并签出一个新的分支: git checkout -b new_branch
- 
select并重置到您想要开始的位置: git log # Find the interesting hash git reset 4b62bdc9087bf33cc01d0462bf16bbf396369c81 --hard或者select git cherry-pick提交来追加到现有的HEAD中。
- 
然后推到你的新回购: git push https://github.com/user/example new_branch:master如果您正在重新绑定,请使用 -f进行强制推送(不推荐)。 运行git reflog查看更改的历史logging。
你真的想把你的本地存储库(包括本地分支机构等)推到新的远程服务器吗?还是你真的想在新的远程服务器上镜像旧的远程服务器(包括所有的分支机构,标签等)? 如果后者是关于如何正确镜像git存储库的好博客。
我强烈build议你阅读一些非常重要的细节,但简短的版本是这样的:
在新目录中运行这些命令:
 git clone --mirror git@example.com/upstream-repository.git cd upstream-repository.git git push --mirror git@example.com/new-location.git 
试试这个https://developer.atlassian.com/blog/2016/01/totw-copying-a-full-git-repo/
- 
在temp-dir目录中使用以下命令创build本地存储库: git clone temp-dir 
- 
进入temp-dir目录。 
- 
要查看ORI中不同分支的列表,请执行以下操作: git branch -a
- 
签出所有你想从ORI复制到新的分支使用: git checkout branch-name
- 
现在使用以下命令从ORI获取所有标签: git fetch --tags
- 
在进行下一步之前,请确保使用以下命令检查本地标签和分支: git tag git branch -a
- 
现在使用以下命令清除到ORI存储库的链接: git remote rm origin
- 
现在使用以下命令将您的本地存储库链接到新创build的新存储库: git remote add origin <url to NEW repo>
- 
现在用这些命令推送你所有的分支和标签: git push origin --all git push --tags
- 
您现在已经从您的ORI回购完整副本。 
我有同样的问题。
在我的情况下,因为我有我的本地机器中的原始存储库,我已经在没有任何隐藏文件(.git,.gitignore)的新文件夹中复制。
最后我将.gitignore文件添加到新build的文件夹中。
然后我创build并从本地path添加了新的存储库(在我的情况下使用GitHub桌面)。