git迁移项目到新命名空间

迁移一个项目到新的命名空间

工作需要迁移了一个项目到新的命名空间,因为项目用到了Gitlab自带的镜像仓库,所以在迁移的时候报错了。
删除镜像仓库中的所有镜像之后,就能够正常转移项目到新的命名空间了。

本地代码仓库指向新的远程仓库

以下为示例操作步骤:

假设当前远程仓库地址为 https://github.com/old-user/old-repo.git,新仓库地址为 https://github.com/new-user/new-repo.git

  1. 查看当前远程仓库地址:

    1
    git remote -v

    输出:

    1
    2
    origin  https://github.com/old-user/old-repo.git (fetch)
    origin https://github.com/old-user/old-repo.git (push)
  2. 修改远程仓库地址:

    1
    git remote set-url origin https://github.com/new-user/new-repo.git
  3. 验证更改:

    1
    git remote -v

    输出应当为:

    1
    2
    origin  https://github.com/new-user/new-repo.git (fetch)
    origin https://github.com/new-user/new-repo.git (push)

完成这些步骤后,你的本地 Git 仓库将会与新的远程仓库地址关联。