Push to GitHub:could not resolve host: github.com


系统:Mac os x 10.11.3

操作:Push to GitHub

错误如下: 
git push origin 
ssh: Could not resolve hostname ssh.github.com: Name or service not known 
fatal: Could not read from remote repository.

Please make sure you have the correct access rights 
and the repository exists. 
make: * [deploy] 错误 128

解决方式1: 
step1. ping github.com 
获取到github.com的ip为192.30.252.128 
step2. 在/etc/hosts(可以通过shift+command+g快速跳转)中添加一行如下: 
192.30.252.128 github.com

 

解决方式2: 
以root权限执行如下python代码

 

 1 #!/usr/bin/python
 2 #coding=utf8
 3 
 4 import socket
 5 
 6 host = 'github.com'
 7 
 8 try:
 9     with open('/etc/hosts', 'a+') as fp: 
10         ip = socket.gethostbyname(host)
11         fp.write(' '.join([ip, host, '\n']))
12 except BaseException as e:
13     print(e)
14 else:
15     print('sucess')

 

特别的:部分朋友找不到/etc/hosts

参考办法:

第一步:请先打开 Mac 系统中的 Finder 应用,

第二步:请按快捷键组合 Shift+Command+G 三个组合按键,并输入 Hosts 文件的所在路径:/etc/hosts,

第三步:随后即可在 Finder 窗口中看到 Hosts 文件了,

第四步:拷贝出来修改后拖回覆盖即可生效,就此成功,去尽情的push吧。

 

向原者致敬,我刚才碰到这个问题,整理分享给大家。

http://blog.csdn.net/piaotiejun/article/details/48734175


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM