假设我在git.fedorahosted.org上有一个存储库,我想将其克隆到我在github的帐户中,以拥有自己的游乐场,而不是在fedorahosted上更“官方”的回购。 最初复制的步骤是什么? 在github中有一个漂亮的“fork”按钮,但我不能使用这个明显的原因。
我如何跟踪fedorahosting回购到github的变化?
假设我在git.fedorahosted.org上有一个存储库,我想将其克隆到我在github的帐户中,以拥有自己的游乐场,而不是在fedorahosted上更“官方”的回购。 最初复制的步骤是什么? 在github中有一个漂亮的“fork”按钮,但我不能使用这个明显的原因。
我如何跟踪fedorahosting回购到github的变化?
当前回答
这个问题的答案已经被删除了,但有一个有用的链接: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
其他回答
在github创建一个新的回购。 将repo从fedorahosted复制到本地机器。 Git远程重命名上游源 git远程添加源URL_TO_GITHUB_REPO Git push origin master
现在你可以使用它就像任何其他github回购。要从上游导入补丁,只需运行git pull upstream master && git push origin master。
我也遇到过同样的问题。
在我的例子中,由于我在本地机器中有原始的存储库,所以我在一个新文件夹中创建了一个副本,没有任何隐藏文件(。git, .gitignore)。
最后,我将.gitignore文件添加到新创建的文件夹中。
然后,我已经从本地路径创建并添加了新的存储库(在我的情况下使用GitHub Desktop)。
用下面的命令改变GIT的repo URL,简单地指向新的repo:
git remote set-url origin [new repo URL]
例如:git remote set-url origin git@bitbucket.org:Batman/batmanRepoName.git
现在,推和拉与新的回购挂钩。
然后像这样正常地推:
git push -u origin master
我做到这一点的方法是:
在github上创建一个新的repo (new-repo.git) CD old-repo/在本地机器上获取所有新的更改 Git push -u https://github.com/[username]/new-repo.git main -f 将新的远程repo https://github.com/[username]/new-repo.git克隆到本地环境
我发现这是一个简单的方法,基本上复制一个旧的远程回购到一个新的远程回购。
首先,在Github上创建你的回购。然后将目录更改为签出的源存储库—假设您想要推送主分支。你需要执行5个简单的步骤:
git remote add origin2 https://github.com/user/example.git
git checkout master
git pull
git push origin2 master
git remote remove origin2
这将在本地回购和新的远程之间创建链接,签出并拉出源分支(以确保它有最新的分支),然后推入当前分支,最后从远程断开本地回购的链接。
在此之后,您的本地回购将是完整的,您可以像以前一样使用它。如果需要推送多个分支,可以根据需要多次重复签出-拉-推步骤,只需相应地更改分支名称即可。