You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Git Push提示无效用户名或密码,无法输入Access Token求助

解决Git Push认证失败且无法输入凭证的问题

1. 先核对远程仓库地址一致性

你克隆的仓库地址是https://github.com/MosabAhmed/BostonHouse.git,但报错指向的是https://github.com/MosabAhmed/BostonHousePrice.git/,两者不匹配。先确认本地仓库关联的远程地址:

git remote -v

若确实指向错误地址,执行命令修改为正确地址:

git remote set-url origin https://github.com/MosabAhmed/BostonHouse.git

2. 清除本地Git缓存的旧凭证

Git可能缓存了之前错误的认证信息,导致跳过凭证输入环节。根据你的操作系统执行对应命令:

  • Windows:打开命令提示符运行:
    git config --global credential.helper wincred
    git credential-manager erase https://github.com
    
  • macOS:在终端执行:
    git credential-osxkeychain erase https://github.com
    
  • Linux:执行:
    git config --global credential.helper store
    rm ~/.git-credentials
    

3. 直接将Access Token嵌入远程地址

跳过凭证输入步骤,把Access Token直接写入HTTPS地址:

git remote set-url origin https://<你的GitHub用户名>:<生成的Access Token>@github.com/MosabAhmed/BostonHouse.git

替换<你的GitHub用户名>和<生成的Access Token>为实际内容,之后执行git push即可。

4. 切换到SSH协议(长期推荐方案)

如果HTTPS凭证问题反复出现,改用SSH协议:

  1. 生成SSH密钥(无密钥时执行):
    ssh-keygen -t ed25519 -C "你的GitHub注册邮箱"
    
  2. 将本地公钥(默认路径~/.ssh/id_ed25519.pub内的内容)添加到GitHub账号的SSH密钥列表中
  3. 修改本地仓库远程地址为SSH格式:
    git remote set-url origin git@github.com:MosabAhmed/BostonHouse.git
    

后续push操作无需再输入凭证。


内容的提问来源于stack exchange,提问作者MOSAB FATAH

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.15 18:57:37