简体   繁体   English

为什么从github仓库通过https的“ git pull”命令需要“ sudo”作为前缀?

[英]Why “git pull” command over https from github repository need “sudo” as prefix?

My OS is ubuntu, I have some codes located on github.com, everything is ok before, but one day, when I typing: 我的操作系统是ubuntu,我在github.com上有一些代码,以前一切正常,但是有一天,当我键入以下内容时:

git pull git pull

I'm asked to input password as usual, and then I get this error. 要求我照常输入密码,然后出现此错误。

error: couldn't connect to host while accessing https://ghosert@github.com/ghosert/VimProject.git/info/refs fatal: HTTP request failed 错误:访问https://ghosert@github.com/ghosert/VimProject.git/info/refs时无法连接到主机致命:HTTP请求失败

until I try sudo prefix like: 直到我尝试像这样的sudo前缀:

sudo git pull 须藤git pull

It works as before once again. 它再次像以前一样工作。 It seems I lost the permission on accessing https when git need it. 似乎当git需要它时,我失去了访问https的权限。 Anyone has idea on this? 有人对此有想法吗?

The error you posted doesn't indicate that the problem was permissions. 您发布的错误并不表示问题是权限。

error: couldn't connect to host while accessing
https://ghosert@github.com/ghosert/VimProject.git/info/refs fatal: HTTP request failed  

"HTTP request failed" sounds like a connectivity problem. “ HTTP请求失败”听起来像是连接问题。

I would simply bet that your internet connection failed when you typed it the first time, and was back up when you typed it again, with sudo , which I doubt had any effect on fixing the problem. 我敢打赌,第一次使用sudo时,您的互联网连接会失败,而当您再次键入时,互联网连接会恢复,我怀疑这对解决问题没有任何作用。

Worse, it probably messed up your permissions now, refer to sarnold's answer. 更糟糕的是,它现在可能会弄乱您的权限,请参阅sarnold的答案。

I faced the same problem today and here is my analysis and solution. 我今天遇到了同样的问题,这是我的分析和解决方案。

I set proxy settings system wide in my chrome browser for some purpose and it seems that it has created some environment variables which are causing my working shell to believe that their is no connectivity as i killed the proxy server when the job was finished. 我出于某种目的在chrome浏览器中设置了代理设置系统范围,似乎它已经创建了一些环境变量,这些变量导致我的工作shell认为它们没有连通性,因为我在完成工作时杀死了代理服务器。 The env variables were not removed. env变量未删除。

Check if your env has some unnecessary variables set. 检查您的环境是否设置了一些不必要的变量。 env --this command will show all the env variables set in you shell. env-此命令将显示您在shell中设置的所有env变量。

Variables: 变量:

http_proxy, https_proxy http_proxy,https_proxy

Remove them and everything will work. 删除它们,一切正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM