github tricks - Serbipunk/notes GitHub Wiki
troubleshooting log
(base) mb@mb:~/git/glsl_testfield$ git push
Enumerating objects: 17, done.
Counting objects: 100% (17/17), done.
Delta compression using up to 12 threads
Compressing objects: 100% (9/9), done.
Writing objects: 100% (9/9), 868 bytes | 289.00 KiB/s, done.
Total 9 (delta 5), reused 0 (delta 0), pack-reused 0
Password for 'https://[email protected]':
error: RPC failed; HTTP 401 curl 22 The requested URL returned error: 401
send-pack: unexpected disconnect while reading sideband packet
fatal: the remote end hung up unexpectedly
Everything up-to-date
(base) mb@mb:~/git/glsl_testfield$ ssh -T [email protected]
Hi Serbipunk! You've successfully authenticated, but GitHub does not provide shell access.
(base) mb@mb:~/git/glsl_testfield$ git remote -v
origin https://[email protected]/Serbipunk/glsl_testfield.git (fetch)
origin https://[email protected]/Serbipunk/glsl_testfield.git (push)
(base) mb@mb:~/git/glsl_testfield$ git remote set-url origin [email protected]:Serbipunk/glsl_testfield.git
(base) mb@mb:~/git/glsl_testfield$ git push
Enumerating objects: 17, done.
Counting objects: 100% (17/17), done.
Delta compression using up to 12 threads
Compressing objects: 100% (9/9), done.
Writing objects: 100% (9/9), 868 bytes | 289.00 KiB/s, done.
Total 9 (delta 5), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (5/5), completed with 5 local objects.
To github.com:Serbipunk/glsl_testfield.git
fc55cdb..0e49aac main -> main
gpt answer
解决方法 2:使用Personal Access Token
如果你使用HTTPS而不是SSH,可以尝试以下步骤:
生成Personal Access Token:
前往 [GitHub Token 生成页面](https://github.com/settings/tokens)。
点击 Generate new token,选择合适的权限,如 repo、workflow 等,然后生成Token。
使用Token进行Push: 当Git提示输入密码时,使用 生成的Token 作为密码。
或者,你可以将Token直接存储到远程URL中:
bash
Copy code
git remote set-url origin https://<your-username>:<your-token>@github.com/<your-username>/<your-repository>.git
注意: 出于安全原因,不建议在终端明文存储Token。
解决方法 3:缓存凭证
如果你使用HTTPS并希望避免每次都输入Token,可以缓存凭证:
启用凭证缓存:
bash
Copy code
git config --global credential.helper cache
或者使用 store(明文存储在本地):
bash
Copy code
git config --global credential.helper store
尝试 git push,首次输入Token后,它将会被缓存。
总结
推荐使用SSH 方式连接GitHub,避免频繁输入Token或密码。
如果需要继续使用HTTPS,请生成 Personal Access Token 并缓存凭证。
你可以尝试这些方法,看是否解决问题。如果还有任何问题,可以告诉我详细的报错信息,我会进一步帮你解决。
https://levelup.gitconnected.com/fix-password-authentication-github-3395e579ce74
https://1drv.ms/b/s!AlX4pw_yn-5RmQ-T2fWQVWuqo2Oe?e=D79iSP
@23112023
https://techglimpse.com/git-push-github-token-based-passwordless/
push like:
git push https://<GITHUB_ACCESS_TOKEN>@github.com/<GITHUB_USERNAME>/<REPOSITORY_NAME>.git
pra - upload build artifacts from PR to this PR comment post.