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

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

问题描述

我需要将现有的 repo 克隆到新的 repo 中.存储库托管在 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 新目录
  2. cd 新目录
  3. git clone ssh://git@git.xyz.com:8888/Project/repo.git
  4. git remote rm origin (从现有 repo 中删除原点)
  5. git remote add origin 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.

我在这里缺少什么?

推荐答案

这在Move git repo with git clone --镜像和 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)

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

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