我需要将现有的存储库克隆到一个新的存储库中。存储库托管在gitlab上。现在,我已经创建了一个新的gitlab存储库,并将现有的存储库克隆到了新的存储库中。
到目前为止,一切正常。我使用命令检查了分支 git branch -a -它显示了所有远程分支。
git push -u origin --all
(导致只将master推送到新的git repo。我想了解为什么所有分支都没有克隆到新目录中。)
我想将所有代码从现有存储库推送到新代码,包括分支,标签和所有内容。
我在这里想念什么?
答案 0 :(得分:1)
“ Move git repo with git clone --mirror and git push --mirror”中对此进行了说明
对于您来说,using git clone --mirror
:
git clone --mirror ssh://git@git.xyz.com:8888/Project/repo.git
cd repo.git
git remote set-url origin ssh://git@git.xyz.com:8888/Project/Newrepo.git
git push --mirror
请注意使用git remote set-url
(而不是删除/添加)
答案 1 :(得分:0)
我认为您应该尝试使用--mirror
选项,即运行命令git push --mirror origin
-镜子
指定每个refs /(包括但不限于refs / heads /, refs / remotes /和refs / tags /)被镜像到远程存储库。 新创建的本地引用将在本地推送到远程端 更新的参考将在远程端强制更新,并且删除的参考 将从远端移除。如果 配置选项remote..mirror已设置。