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. 提交代码
git add .
git commit -m 'aisi init'
git push
7. 还有重要的一步, 在gitlab后台修改默认分支
广告: 朋友圈自动点赞工具: aisisoft.top