Mac电脑中git更改帐号密码配置后,github远程仓库拉取项目仍出现Repository not found.

情况说明

  1. Mac电脑
  2. 已有账号已经更换成自己的user.name和user.email
node 复制代码
	git config --global user.name "xxx"
	git config --global user.email "xxx"
  1. 钥匙串访问中无法清除github.com记录
  2. 拉取自己的私有github远程仓库,或push已拉取的项目时提示Repository not found

原因

Mac 上还缓存着前一个用户的 GitHub 登录凭证(可能是在钥匙串、SSH key 或 HTTPS token 中),所以即使换了名字和账号,拉取的时候还是用她的权限去访问。

具体操作

步骤一:强制清空钥匙串中的github.com记录

说明Mac 钥匙串里,这条 GitHub 登录记录是"正在被使用 "或者"被权限保护"的,所以直接右键删它没反应。需要用终端命令去删。

1. 删除 GitHub 旧凭证

终端输入

node 复制代码
security delete-internet-password -s github.com
2. 确认是否删除成功

查看钥匙串里还有没有github

node 复制代码
security find-internet-password -s github.com

如果输出是

node 复制代码
security: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.

说明 GitHub 凭证已经清掉了

步骤二:创建token

  1. 登录 GitHub
  2. 右上角头像 → Settings
  3. 左侧 Developer settingsPersonal access tokensTokens (classic)
  4. 点击 Generate new token (classic)
  5. 选择过期时间(建议 90 天或更长),全部勾选
  6. 生成后 复制 token(以后看不到了)

步骤三:重新clone或push进行认证

git clone/push代码后会弹出输入用户名/密码

username:你的github用户名

password:你的 Personal Access Token (不是 GitHub 登录密码)

步骤四:让git自动保存到macOS钥匙串

node 复制代码
git config --global credential.helper osxkeychain

这个命令告诉 Git:以后记住我输入的 Token,存到钥匙串里。

步骤五:验证是否保存成功

node 复制代码
security find-internet-password -s github.com

如果能看到记录,就说明保存成功了。

步骤六:以后 push / pull / clone Git会从钥匙串中直接读取token,自动鉴权

✅Over

相关推荐
eduics2 小时前
Pull Request 中提示`commits incorrectly signed off`
gitee·github
养鱼的程序员4 小时前
零基础搭建个人网站:从 Astro 框架到 GitHub 自动部署完全指南
前端·后端·github
mortimer7 小时前
Python GUI 应用启动优化实战:从3分钟到“秒开”的深度历程
python·github·pyqt
三道杠卷胡7 小时前
【AI News | 20250804】每日AI进展
人工智能·python·语言模型·github·aigc
微凉的衣柜7 小时前
GitHub Models:为开源AI项目解决推理难题,让AI更易用、更普及
人工智能·开源·github
华洛7 小时前
关于可以控制大模型提升任意产品的排名这件事📈
前端·github·产品经理
艾迪的技术之路10 小时前
Superset安装步骤
后端·面试·github
油泼辣子多加12 小时前
2025年08月04日Github流行趋势
github
喵叔哟12 小时前
37.【.NET8 实战--孢子记账--从单体到微服务--转向微服务】--扩展功能--增加Github Action
微服务·github·.net