GitLab更换远程仓库地址, 老是报错:
error: src refspec master does not match any
error: failed to push some refs to 'http://www.aisisoft.cn/xxx/xxx.git'
或是拒绝
fatal: refusing to merge unrelated histories
最后发现还是主分支main的问题, 使用分支master就可以了. 具体步骤如下:
1. 查看git的远程仓库地址:
git remote -v
origin http://www.aisi.cn/xx/xxx.git (fetch)
origin http://www.aisi.cn/xx/xxx.git (push)
2. 如果上面的远程地址不是你想要的, 删除git, 重来
rm -rf .git
3. git 初始化
git init
4. 加入新仓库地址
git remote add origin http://aisisoft.cn/xxx/newxxx.git
5. 写入分支, 注意是master, 不要写成main
git push -uf origin master
6. 提交代码
本文介绍了在GitLab中遇到更换远程仓库地址时遇到的错误问题,特别是主分支从main改为master的情况。详细步骤包括查看当前远程仓库地址、删除并重新设置仓库、初始化git、添加新仓库地址、指定master分支以及在GitLab后台调整默认分支。
最低0.47元/天 解锁文章
5655

被折叠的 条评论
为什么被折叠?



