先讲原因:pull Github仓库时用了HTTPS。需要是SSH。
把本地仓库远程地址改为 SSH 地址,再重新push就可以了。
来看下具体情况。
在IDEA中改好代码,push时报错了:
PyCharm cosole也有报错:
fatal: could not read Username for ‘https://github.com': Device not configured Remote "origin" does not support the Git LFS locking API. Consider disabling it with: $ git config lfs.https://github.com/helloworldtang/GPT_teacher-3.37M-cn.git/info/lfs.locksverify false Git credentials for https://github.com/helloworldtang/GPT_teacher-3.37M-cn.git not found: credential fill errors: exit status 1 error: failed to push some refs to ’https://github.com/helloworldtang/GPT_teacher-3.37M-cn.git';
错哪了?没有配置用户名密码?
之前已经在Github上配置过SSH密钥了。
再来GitHub → Settings → SSH and GPG keys → New SSH key检查一下:
你说的都对,but为什么报错了?
看报错信息中是
https://github.com/helloworldtang/GPT_teacher-3.37M-cn.git
配置的SSH Key,是不是不匹配?
问题解决。
习惯使用git命令行的同学,操作路径如下:
1、检查本地 SSH 密钥:
打开终端,执行:
ls -la ~/.ssh
若存在 id_rsa/id_ed25519(私钥)和 id_rsa.pub/id_ed25519.pub(公钥),跳过步骤 2;否则生成密钥:
2、生成 SSH 密钥:
ssh-keygen -t ed25519 -C "" # 替换为你的 GitHub 邮箱
按回车默认保存路径,无需设置密码(或按需设置)。
Ed25519 是基于扭曲爱德华曲线(Twisted Edwards Curve) 的椭圆曲线加密(ECC)算法,由 Daniel J. Bernstein 等人设计,是目前最安全、高效的非对称加密 / 签名算法之一,广泛用于 SSH、TLS、密码学库(如 libsodium)、区块链等场景。 Ed25519详解
3、添加 SSH 密钥到 GitHub:
cat ~/.ssh/id_ed25519.pub # 若用 RSA 则是 cat ~/.ssh/id_rsa.pub
4、修改本地仓库的远程地址为 SSH
cd /Users/username/GPT_teacher-3.37M-cn git remote set-url origin :helloworldtang/GPT_teacher-3.37M-cn.git
5、测试 SSH 连接:
ssh -T
若输出 Hi helloworldtang! You‘ve successfully authenticated…,说明配置成功。
6、重新推送
git push origin feature/gpu-train-accel
success.
完成。
tips: GitHub 推荐使用 SSH 协议进行 Git 操作,无需每次输入密码,且稳定性更高。
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/262097.html