GitHub项目迁移到GitLab
GitHub项目迁移到GitLab
1.克隆GitHub项目到本地
[root@gitclient ~]# mkdir gitrepos [root@gitclient ~]# cd gitrepos [root@gitclient gitrepos]# git init . hint: Using 'master' as the name for the initial branch. This default branch name hint: is subject to change. To configure the initial branch name to use in all hint: of your new repositories, which will suppress this warning, call: hint: hint: git config --global init.defaultBranch <name> hint: hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and hint: 'development'. The just-created branch can be renamed via this command: hint: hint: git branch -m <name> Initialized empty Git repository in /root/gitrepos/.git/ [root@gitclient gitrepos]# git clone https://github.com/xxx/easy-springmvc-maven.git Cloning into 'easy-springmvc-maven'... remote: Enumerating objects: 48, done. remote: Counting objects: 100% (3/3), done. remote: Compressing objects: 100% (3/3), done. remote: Total 48 (delta 0), reused 2 (delta 0), pack-reused 45 (from 1) Receiving objects: 100% (48/48), 9.16 KiB | 1.53 MiB/s, done. Resolving deltas: 100% (9/9), done. [root@gitclient gitrepos]# ls easy-springmvc-maven
2. 在GitLab上创建同名新项目
3. 本地仓库重设远程仓库
[root@gitclient gitrepos]# cd easy-springmvc-maven/ [root@gitclient easy-springmvc-maven]# git remote -v origin https://github.com/xxx/easy-springmvc-maven.git (fetch) origin https://github.com/xxx/easy-springmvc-maven.git (push) [root@gitclient easy-springmvc-maven]# git remote set-url origin git@192.168.100.31:plat-group/easy-springmvc-maven.git [root@gitclient easy-springmvc-maven]# git remote -v origin git@192.168.100.31:plat-group/easy-springmvc-maven.git (fetch) origin git@192.168.100.31:plat-group/easy-springmvc-maven.git (push) [root@gitclient easy-springmvc-maven]#
4. push代码到GitLab
[root@gitclient easy-springmvc-maven]# git push origin main:main Enumerating objects: 48, done. Counting objects: 100% (48/48), done. Compressing objects: 100% (32/32), done. Writing objects: 100% (48/48), 9.16 KiB | 9.16 MiB/s, done. Total 48 (delta 9), reused 48 (delta 9), pack-reused 0 To 192.168.100.31:plat-group/easy-springmvc-maven.git * [new branch] main -> main [root@gitclient easy-springmvc-maven]#
注:冒号前为本地分支,冒号后为远程分支,远程分支没有则创建。
5. 其他
5.1 报错解决
-
报错:
To 192.168.100.31:plat-group/easy-springmvc-maven.git
! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push[root@gitclient easy-springmvc-maven]# git push origin main:main Enumerating objects: 48, done. Counting objects: 100% (48/48), done. Compressing objects: 100% (32/32), done. Writing objects: 100% (48/48), 9.16 KiB | 9.16 MiB/s, done. Total 48 (delta 9), reused 48 (delta 9), pack-reused 0 remote: GitLab: remote: A default branch (e.g. main) does not yet exist for plat-group/easy-springmvc-maven remote: Ask a project Owner or Maintainer to create a default branch: remote: remote: http://192.168.100.31/plat-group/easy-springmvc-maven/-/project_members remote: To 192.168.100.31:plat-group/easy-springmvc-maven.git ! [remote rejected] main -> main (pre-receive hook declined) error: failed to push some refs to '192.168.100.31:plat-group/easy-springmvc-maven.git' -
原因:
权限不够
-
解决办法:
把GitLab用户设置为administrator,
本文来自博客园,作者:何以卿卿,转载请注明原文链接:https://www.cnblogs.com/shiqiang-lee/p/18609873
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!