# 错误：命令以退出状态 128 出错：git clone --filter=blob:none 'https://github.com/user/private-repo.git' /tmp/pip-req-build-xxxxx。检查日志以获取完整命令输出。

- **ID:** `pip/git-clone-authentication-failure`
- **领域:** pip
- **类别:** auth_error
- **错误码:** `ERROR`
- **验证级别:** ai_generated
- **修复率:** 88%

## 根因

Pip 克隆私有 Git 仓库失败，因为用户未提供有效的身份验证凭据（例如 SSH 密钥、个人访问令牌或密码）给远程 Git 服务器。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| pip 21.0+ | active | — | — |
| Git 2.30+ | active | — | — |
| Python 3.10 | active | — | — |

## 解决方案

1. ```
   在 URL 中使用个人访问令牌：pip install git+https://<token>@github.com/user/private-repo.git
   ```
2. ```
   配置 SSH 密钥并使用 SSH URL：pip install git+ssh://git@github.com/user/private-repo.git
   ```
3. ```
   首先手动克隆仓库，然后从本地路径安装：git clone https://github.com/user/private-repo.git /tmp/repo && pip install /tmp/repo
   ```

## 无效尝试

- **Using https:// URL without credentials and expecting cached credentials to work** — Git credential caching may be expired or misconfigured, and pip does not prompt for credentials interactively in non-TTY environments. (50% 失败率)
- **Setting git config --global http.proxy incorrectly** — Wrong proxy settings can cause authentication to be routed incorrectly or block the connection entirely. (30% 失败率)
- **Using sudo pip install with a personal SSH key** — Running pip as root changes the SSH agent context, often losing access to the user's SSH keys. (60% 失败率)
