git pull 给出错误:访问 https://git.foo.com/bar.git 时需要 401 授权
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16572286/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
git pull gives error: 401 Authorization Required while accessing https://git.foo.com/bar.git
提问by spuder
My macbook pro is able to clone/push/pull from the company git server. My cent 6.3 vm gets a 401 error
我的 macbook pro 能够从公司的 git 服务器克隆/推/拉。我的 cent 6.3 vm 出现 401 错误
git clone https://git.acme.com/git/torque-setup
"error: The requested URL returned error: 401 Authorization Required while accessing https://git.acme.com/git/torque-setup/info/refs
As a work around, I've tried creating a folder, with an empty repository, then setting the remote to the company server. I get the same error when trying a git pull
作为解决方法,我尝试创建一个文件夹,其中包含一个空存储库,然后将远程设置为公司服务器。尝试 git pull 时出现同样的错误
The remotes are identical between the machines
机器之间的遥控器是相同的
MacBook Pro(working)
MacBook Pro(工作中)
git --version
git version 1.7.10.2 (Apple Git-33)
git remote -v
origin https://git.acme.com/git/torque-setup (fetch)
origin https://git.acme.com/git/torque-setup (push)
Cent 6.3(not working)
Cent 6.3(不工作)
yum install -y git
git --version
git version 1.7.1
git remote -v
origin https://git.acme.com/git/torque-setup (fetch)
origin https://git.acme.com/git/torque-setup (push)
The git server only allows https. Not git or ssh connections.
git 服务器只允许 https。不是 git 或 ssh 连接。
Why is the macbook pro able to do a git pull, while the cent os machine can't?
为什么macbook pro 可以做git pull,而cent os 机器不行?
Solution Update 2013-5-15
解决方案更新 2013-5-15
As jku mentioned, the culprit is the old version of git installed on the cent box. Unfortunately, 1.7.1 is what you get when you run yum install git
正如jku所提到的,罪魁祸首是安装在cent box上的旧版本git。不幸的是,1.7.1 是你运行时得到的yum install git
The work around is to manually install a newer version of git, or simply add the username to the repo
解决方法是手动安装较新版本的 git,或者简单地将用户名添加到 repo
git clone https://[email protected]/git/torque-setup
采纳答案by Jussi Kukkonen
I would update the git version: 1.7.10 (or thereabouts) had authentication improvements. It's possible that these improvements were only related to proxies though -- I've forgotten the details already.
我会更新 git 版本:1.7.10(或大约)有身份验证改进。不过,这些改进可能只与代理有关——我已经忘记了细节。
Speaking of proxies, you could double-check git config: You wouldn't have proxies or anything like that configured on the macbook but not on the cent machine?
说到代理,你可以仔细检查 git config:你不会在 macbook 上配置代理或类似的东西,但在 cent 机器上没有?
回答by cao song
I had the same error:
我有同样的错误:
error: The requested URL returned error: 401 while accessing
fatal: HTTP request failed
To fix it, I did the following:
为了解决这个问题,我做了以下事情:
check git version: 1.7.1
update git