push failed:Unable to access ‘https://gitee(github).com/仓库名‘

在换了网络后可能会出现上面这种情况,通过修改hosts文件可以解决

  • 先确认下网络情况
    浏览器打开仓库或其他网页试试,可以打开的话就说明网络没问题。那如果打不开呢?亲,这边建议您切换下网络试试
    排除网络原因后

  • 获得电脑的ip地址
    打开命令行,输入–>ipconfig
    push failed:Unable to access ‘https://gitee(github).com/仓库名‘

复制IPv4地址

  • 修改hosts文件
    找到git的安装目录/etc/hosts
    push failed:Unable to access ‘https://gitee(github).com/仓库名‘
    右键点击用记事本或Notepad等软件打开
    如果是连接gitee失败就在最一行加上(中间有空格)
    ip地址 gitee.com
    如果是连接github失败就在最一行加上(中间有空格)
    ip地址 github.com
    如下图所示:
    push failed:Unable to access ‘https://gitee(github).com/仓库名‘
    完成后再重新commit、push试试吧