将存储库克隆到新项目中,然后将其推送到gitlab [英] cloning a repo into a new project and then push it to gitlab

查看:78
本文介绍了将存储库克隆到新项目中,然后将其推送到gitlab的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a need to clone an existing repo into a new one. Repositories are hosted on gitlab. For now i have created a new gitlab repository , and cloned the existing repo into the new one.

  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 -它显示了所有远程分支.

upto here everything worked fine. i checked for branches using command git branch -a - it showed all remote branches.

git push -u origin --all

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

( it resulted in pushing only master to the new git repo.I want to understand why all the branches are not cloned into the new directory.)

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

I want to push all the code from existing repo to new including branches, tags and everything.

我在这里想念什么?

推荐答案

"使用git clone移动git repo进行了说明-镜像和git push --mirror "

在您的情况下,请使用git clone --mirror :

In your case, 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 (而不是删除/添加)

Note the use of git remote set-url (instead of remove/add)

这篇关于将存储库克隆到新项目中,然后将其推送到gitlab的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆