IntelliJ IDEA中Git报错:找不到项目或无权限访问的解决求助
解决IntelliJ IDEA 2021.3.3中Git操作权限错误问题
问题背景
- 环境:IntelliJ IDEA 2021.3.3(旗舰版)、Windows 10
- 症状:IDEA内执行更新、推送、克隆项目操作时,均报错:
remote: The project you were looking for could not be found or you don't have permission to view it.
所有工作仓库今日出现该问题,昨日一切正常;但PowerShell中执行git clone、Git UI界面可正常访问下载仓库。
已尝试的排查操作
- 重新安装Git
- 重建settings.xml
- 在IDEA终端使用带登录信息的Git命令(
https://{gitlab_user}@gitlab.com/gitlab_user/project_repo.git),仍无效 - 执行
File -> Invalidate Caches..操作 - 执行
File -> Repair IDE..操作 - 在
Settings -> Appearence and Behavior -> Password中清除密码 - 在
Settings -> Version Control -> Git中点击Test按钮可正常返回Git版本 - 在Windows Account Manager中清除Git凭据
解决方案
1. 配置IDEA的Git平台账户认证
针对GitLab平台,推荐使用个人访问令牌(PAT)完成认证:
- 打开IDEA,进入
File > Settings > Version Control > GitLab - 点击
Add Account,选择GitLab选项 - 在登录窗口中,输入GitLab用户名,密码栏填入个人访问令牌(需提前在GitLab账户设置中生成,权限勾选
read_repository、write_repository) - 完成登录后,重新尝试Git操作
2. 启用IDEA的Git凭据助手
让IDEA调用系统Git的凭据管理功能:
- 进入
File > Settings > Version Control > Git - 勾选
Use credential helper选项 - 重启IDEA,执行Git操作时会弹出登录验证窗口,输入正确的账号或令牌完成认证
3. 手动修改仓库远程地址(针对已克隆仓库)
- 打开目标仓库,进入
Git > Manage Remotes - 选中远程仓库(如origin),修改URL为带认证信息的格式:
https://{gitlab_user}:{personal_access_token}@gitlab.com/gitlab_user/project_repo.git
将{gitlab_user}替换为你的用户名,{personal_access_token}替换为生成的令牌
4. 检查IDEA代理设置
- 进入
File > Settings > Appearance & Behavior > System Settings > HTTP Proxy - 确保代理设置与PowerShell、Git UI一致,若无需代理则选择
No proxy,避免代理拦截认证请求
内容的提问来源于stack exchange,提问作者Vicheslav
相关产品推荐
相关产品推荐

