現象1:ssh: Could not resolve hostname git: nodename nor servname provided, or not known
fatal: Could not read from remote repository.
現象2:fatal: unable to access 'https://xx.git/': Could not resolve host: github.com
解決方式:(以mac為例)
1.打開finder---->然后cmd+shift+g--->輸入/etc/hosts 然后打開hosts文件
2.找到
# Github start
192.30.253.112 github.com
# Github end
注意:
192.30.253.112 這個地址會變,不一定是這個;
github.com 必須是這個地址,不能有其他東西(本人就是在翻墻的時候復制過來的hosts文件中上面的地址是 gist.github.com導致的這個問題,只能說holy shit!!)
如果在hosts文件中沒有找到這幾行代碼,就添加上;
也試過windows中出現這種問題,一般都是沒有這幾行代碼,至于windows的hosts文件自己問度娘吧!