当前位置:   article > 正文

git remote更换远程仓库地址_git更换remote

git更换remote

本人电脑已经配置好了git,公司的项目是搭建在gitblit中,最后提交代码的时候报错

fatal: Could not read from remote repository. Please make sure you have the

刚开始以为是SSH Key没有添加,去重新生成一个key 添加了一遍,发现还是报同样的错误

后来以为是需要配置多个git账号,一通配置下来还是没有用,最后发现是 git remote 地址的问题

git remote -v 查看远程仓库地址,和代码库的地址比对了一下,发现当初clone项目的时候是用的,最下面那个地址,应该是没有推送权限的

然后,更换远程仓库地址方法

方法一:通过git修改你的远程仓库

  1. // 直接修改仓库地址
  2. git remote set-url origin https://github.com/xxxxxxxxx/xxxx.git
  3. // 删除重新添加
  4. git remote rm origin     //删除
  5. git remote add origin https://github.com/xxxxxxxxx/xxxx.git   //添加新的地址

方法二: 直接修改你本地的.git文件

在项目里面有一个 .git 文件夹 打开 .git 文件夹下 config 文件,直接修改 URL 就可以了

我用的第一种方法,问题已解决

后续项目又碰到一个错误

fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

 是因为和远程断开了连接, 直接添加远程仓库即可

git remote add origin https://github.com/xxxxxxxxx/xxxx.git   //添加新的地址

本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号