无法通过HTTPS在Linux上克隆github repo [英] Can't clone a github repo on Linux via HTTPS
问题描述
我试图在CentOS盒子上做一个简单的 git clone https://github.com/org/project.git
,但得到:
错误:请求的URL在访问
https://github.com/org/project.git/info/refs
$ b 致命:HTTP请求失败 p>
它永远不会提示我输入用户名/密码,只会失败。
I可以在我的Mac上进行完全相同的调用没有问题 - 我错过了什么?
答案很简单,但并不明显:
而不是:
git克隆https://github.com/org/project.git
do:
git克隆https://username@github.com/org/project.git
或(不安全)
GIT中克隆https://用户名:password@github.com/org/project.git
(请注意,在后一种情况下,通过运行 ps u -u $ you
,您的密码可能会被计算机上的其他用户看到,并且默认情况下会在shell的历史记录中显示为明文)
所有3种方式都可以在我的Mac上使用,但只有最后两种方式在远程Linux机器上运行。 (回想一下,这可能是因为我有一个全球git用户名在我的Mac上设置,而在远程盒子上,我没有?可能是这种情况,但缺少提示输入用户名的提示......)
在任何地方都没有见过这种文件,所以在这里。
I'm trying to do a simple git clone https://github.com/org/project.git
on a CentOS box but get:
error: The requested URL returned error: 401 while accessing https://github.com/org/project.git/info/refs
fatal: HTTP request failed
It never prompts me for my username/password, just fails.
I can make the exact same call on my Mac no problem- what am I missing?
The answer was simple but not obvious:
Instead of:
git clone https://github.com/org/project.git
do:
git clone https://username@github.com/org/project.git
or (insecure)
git clone https://username:password@github.com/org/project.git
(Note that in the later case, your password will may be visible by other users on your machine by running ps u -u $you
and will appear cleartext in your shell's history by default)
All 3 ways work on my Mac, but only the last 2 worked on the remote Linux box. (Thinking back on this, it's probably because I had a global git username set up on my Mac, whereas on the remote box I did not? That might have been the case, but the lack of prompt for a username tripped me up... )
Haven't seen this documented anywhere, so here it is.
这篇关于无法通过HTTPS在Linux上克隆github repo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!