将存储库克隆到新项目中,然后将其推送到gitlab

时间:2019-09-12 01:52:45

标签: git gitlab

我需要将现有的存储库克隆到一个新的存储库中。存储库托管在gitlab上。现在,我已经创建了一个新的gitlab存储库,并将现有的存储库克隆到了新的存储库中。

  1. mkdir newDirectory
  2. cd newDirectory
  3. git clone ssh://git@git.xyz.com:8888 / Project / repo.git
  4. git remote rm origin(删除现有仓库中的起源)
  5. git远程添加来源ssh://git@git.xyz.com:8888 / Project / Newrepo.git

到目前为止,一切正常。我使用命令检查了分支 git branch -a -它显示了所有远程分支。

git push -u origin --all

(导致只将master推送到新的git repo。我想了解为什么所有分支都没有克隆到新目录中。)

我想将所有代码从现有存储库推送到新代码,包括分支,标签和所有内容。

我在这里想念什么?

2 个答案:

答案 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已设置。