git clone报错

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:使用个人访问令牌(推荐)

  1. Gitee网页:个人设置 → 安全设置 → 个人访问令牌
  2. 生成token,勾选权限:projects(仓库读写),复制保存token(只显示一次)

方式A:clone的时候直接带上token

bash 复制代码
git clone https://你的账号:你的token@gitee.git

方式B:本地已经保存旧错误凭据(Windows重点)

Windows会缓存旧密码/token,需要清除缓存:

  1. 控制面板 → 用户账户 → 凭据管理器 → Windows凭据
  2. 找到 gitee.com 相关条目,全部删除
  3. 重新clone,弹窗用户名填gitee账号,密码粘贴生成的token

方案2:切换SSH地址(不用token,配置密钥)

  1. 生成本地ssh密钥,公钥复制到Gitee个人设置‑SSH公钥
  2. 使用ssh地址clone
bash 复制代码
git clone git@gitee.git

快速自查清单

  1. ❌不要再填登录密码,必须填个人访问令牌作为密码
  2. token是否过期、是否勾选projects仓库权限
  3. Windows凭据管理器是否缓存旧错误信息(高频踩坑)
  4. 确认账号有这个仓库的克隆权限(项目是否给你授权)
  5. 复制token不要带空格换行

如果已经clone过仓库,只是pull失败

进入项目目录执行:

bash 复制代码
git remote set-url origin https://账号:token@gitee.git
git pull
相关推荐
番茄不是西红柿kk9 小时前
deepseek-harness跨平台桌面端二开项目(附git仓库地址+安装包)
git·agent·codex·deepseek·deepseekharness
leoZ23113 小时前
10-Git 仓库蒸馏术:从代码仓库到 OpenClaw 虚拟人-蒸馏工具链
大数据·git·深度学习·神经网络·目标检测·elasticsearch·lstm
fpcc1 天前
工具使用—git diff命令分析说明
git·工具
console.log('npc')1 天前
Git 删除指定提交记录操作指南
git
随风丶飘1 天前
[特殊字符] 告别“update“和“fix bug“——Smart Git Commit LLM 让 AI 帮你写专业的 Git 提交信息
人工智能·git·bug
yanlaifan1 天前
git clone时候指定换行符
git
小小安于乱1 天前
解决IDEA的git插件pull代码冲突但右下角不提示消息问题
java·git·intellij-idea
ITKEY_1 天前
git 命令行操作回退到指定版本
git
New_Horizons6661 天前
Git 操作(使用git-commit-template)
git