Gitee clone报错
remote: [session‑43404b84] 102346@qq.com: Incorrect username or password (access token)
fatal: Authentication failed for 'https://gitee.com.git/'
原因:https方式拉取,账号密码/个人访问令牌(token)错误、令牌过期、令牌权限不足。
Gitee现在不再支持账户密码直接https拉取,必须使用【个人访问令牌】代替密码。
方案1:使用个人访问令牌(推荐)
- Gitee网页:个人设置 → 安全设置 → 个人访问令牌
- 生成token,勾选权限:
projects(仓库读写),复制保存token(只显示一次)
方式A:clone的时候直接带上token
bash
git clone https://你的账号:你的token@gitee.git
方式B:本地已经保存旧错误凭据(Windows重点)
Windows会缓存旧密码/token,需要清除缓存:
- 控制面板 → 用户账户 → 凭据管理器 → Windows凭据
- 找到
gitee.com相关条目,全部删除 - 重新clone,弹窗用户名填gitee账号,密码粘贴生成的token
方案2:切换SSH地址(不用token,配置密钥)
- 生成本地ssh密钥,公钥复制到Gitee个人设置‑SSH公钥
- 使用ssh地址clone
bash
git clone git@gitee.git
快速自查清单
- ❌不要再填登录密码,必须填个人访问令牌作为密码
- token是否过期、是否勾选
projects仓库权限 - Windows凭据管理器是否缓存旧错误信息(高频踩坑)
- 确认账号有这个仓库的克隆权限(项目是否给你授权)
- 复制token不要带空格换行
如果已经clone过仓库,只是pull失败
进入项目目录执行:
bash
git remote set-url origin https://账号:token@gitee.git
git pull