【经验分享】git push 时出现的三种报错及解决方案

  最近在使用 git 进行 git clone 时,经常报错,经过查询找到了一种解决方案,分享给大家。


一、第一种报错

  执行git push 提示 “fatal: unable to access 目标地址: Failed connect to github.com:443; Connection timed out”

[cos@VM-0-14-centos Exercise]$ git push origin master
fatal: unable to access 'https://github.com/cos/Exercise.git/'
: Failed connect to github.com:443; Connection timed out


二、第二种报错

  执行git push 提示 “fatal: remote error: You can’t push to 目标地址 Use 目标地址”

[cos@VM-0-14-centos Exercise]$ git push origin master
fatal: remote error: 
You can't push to https://github.com/cos/Exercise.git
Use https://github.com/cos/Exercise.git

三、第三种报错

  执行git push 提示 “fatal: repository ‘目标地址’ not found”

[cos@VM-0-14-centos Exercise]$ git push origin master
remote: Repository not found.
fatal: repository 'https://github.com/cos/Exercise.git/' not found

四、解决方案

3.1 方案一

  (1) 找到 ./git 文件夹。

image-20210630113745315

  (2) 进入 ./git 文件夹,找到 config 配置文件。

image-20210630113958786

  (3) vim config 打开 config 文件,修改配置文件中的远程地址url,保存并退出。

在这里插入图片描述

  (4) 然后 git push origin master推送到远端仓库。

在这里插入图片描述


3.2 方案二

  (1) 使用下面这一条命令也可以完美解决。注意:user 需要替换成自己的用户名,xxx 需要替换成具体的分支。

git remote set-url origin https://github.com/user/xxx.git

  (2) 然后 git push origin master推送到远端仓库。
image-20210630114946849


Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐