假设我在git.fedorahosted.org上有一个存储库,我想将其克隆到我在github的帐户中,以拥有自己的游乐场,而不是在fedorahosted上更“官方”的回购。 最初复制的步骤是什么? 在github中有一个漂亮的“fork”按钮,但我不能使用这个明显的原因。
我如何跟踪fedorahosting回购到github的变化?
假设我在git.fedorahosted.org上有一个存储库,我想将其克隆到我在github的帐户中,以拥有自己的游乐场,而不是在fedorahosted上更“官方”的回购。 最初复制的步骤是什么? 在github中有一个漂亮的“fork”按钮,但我不能使用这个明显的原因。
我如何跟踪fedorahosting回购到github的变化?
当前回答
下面是手动执行git remote set-url origin[新回购URL]的方法:
Clone the repository: git clone <old remote> Create a GitHub repository Open <repository>/.git/config $ git config -e [core] repositoryformatversion = 0 filemode = false bare = false logallrefupdates = true symlinks = false ignorecase = true [remote "origin"] url = <old remote> fetch = +refs/heads/*:refs/remotes/origin/* [branch "master"] remote = origin merge = refs/heads/master and change the remote (the url option) [remote "origin"] url = <new remote> fetch = +refs/heads/*:refs/remotes/origin/* Push the repository to GitHub: git push
你也可以同时使用两个/多个遥控器。
其他回答
这个问题的答案已经被删除了,但有一个有用的链接: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存储库:
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
我做到这一点的方法是:
在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克隆到本地环境
我发现这是一个简单的方法,基本上复制一个旧的远程回购到一个新的远程回购。
我用set-url找到了一个简洁易懂的解决方案:
在Github创建一个新的回购 CD到本地机器上现有的存储库中(如果您还没有克隆它,那么请先执行此操作) Git远程set-url origin https://github.com/user/example.git Git push -u origin master
试试这个如何移动一个完整的Git存储库
Create a local repository in the temp-dir directory using: git clone temp-dir Go into the temp-dir directory. To see a list of the different branches in ORI do: git branch -a Checkout all the branches that you want to copy from ORI to NEW using: git checkout branch-name Now fetch all the tags from ORI using: git fetch --tags Before doing the next step make sure to check your local tags and branches using the following commands: git tag git branch -a Now clear the link to the ORI repository with the following command: git remote rm origin Now link your local repository to your newly created NEW repository using the following command: git remote add origin <url to NEW repo> Now push all your branches and tags with these commands: git push origin --all git push --tags You now have a full copy from your ORI repo.