问题描述
我正在尝试在 CentOS 机器上做一个简单的 git clone https://github.com/org/project.git
但得到:
I'm trying to do a simple git clone https://github.com/org/project.git
on a CentOS box but get:
错误:请求的 URL 返回错误:访问时返回 401https://github.com/org/project.git/info/refs
致命:HTTP 请求失败
fatal: HTTP request failed
它从不提示我输入用户名/密码,只是失败.
It never prompts me for my username/password, just fails.
我可以在 Mac 上拨打完全相同的电话,没问题 - 我错过了什么?
I can make the exact same call on my Mac no problem- what am I missing?
推荐答案
答案很简单但并不明显:
The answer was simple but not obvious:
代替:
git clone https://github.com/org/project.git
做:
git clone https://username@github.com/org/project.git
或(不安全)
git clone https://username:password@github.com/org/project.git
(请注意,在后一种情况下,您的计算机上的其他用户可能会通过运行 ps u -u $you
看到您的密码,并且默认情况下将在您的 shell 历史记录中以明文形式显示)
(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)
所有 3 种方式都适用于我的 Mac,但只有最后两种方式适用于远程 Linux 机器.(回想一下,可能是因为我有一个 全局 git 用户名 在我的 Mac 上设置,而在远程盒子上我没有?可能是这种情况,但是没有输入用户名的提示让我感到困惑...)
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 存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!