记一次GitHub提交出错

本文解决在Win10的WSL环境中使用Git通过SSH协议提交项目时遇到的账号密码验证失败问题。详细步骤包括检查配置文件、更换远程仓库地址从HTTPS到SSH,以及成功提交代码的过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

问题描述

Win10 WSL安装 Git 后修改提交项目,配置 ssh 秘钥之后,提交需要验证账号密码切失败。报错信息如下

xxp@DESKTOP-7B9JVLI:/mnt/f/notes$ git push origin master
Username for 'https://github.com': pyxxp
Password for 'https://pyxxp@github.com':
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/xxx/notes.git/'

查看配置信息

xxp@DESKTOP-7B9JVLI:/mnt/f/notes$ cat .git/config
[core]
        repositoryformatversion = 0
        filemode = false
        bare = false
        logallrefupdates = true
[remote "origin"]
        url = https://github.com/xxx/notes.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master

我当初复制项目时复制的是 HTTPS 远程仓库地址。而我配置是 SSH 协议。之后把远程仓库协议修改为 SSH 就能提交了。

xxp@DESKTOP-7B9JVLI:/mnt/f/notes$ git remote add origin git@github.com:1621521894/notes.git

xxp@DESKTOP-7B9JVLI:/mnt/f/notes$ git remote -v
origin  git@github.com:1621521894/notes.git (fetch)
origin  git@github.com:1621521894/notes.git (push)

xxp@DESKTOP-7B9JVLI:/mnt/f/notes$ git push origin master
Counting objects: 11, done.
Delta compression using up to 6 threads.
Compressing objects: 100% (10/10), done.
Writing objects: 100% (11/11), 1.88 KiB | 643.00 KiB/s, done.
Total 11 (delta 3), reused 0 (delta 0)
remote: Resolving deltas: 100% (3/3), completed with 3 local objects.
To github.com:1621521894/notes.git
   7ee6ada..59123cd  master -> master

参考:https://stackoverflow.com/questions/12940626/github-error-message-permission-denied-publickey

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值