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