Fix git push failure
Fix git push failure
Problem
One day, I suddenly found that I can not access to my repo directly using git push command.
I tried check connection using
1 | |
everything went well.
So I think the ssh key may have been specified incorrectly, while directly using git push (I also got other ssh keys for other github repositories, which may conflict).
Solution
generate a new ssh key pair
1
ssh-keygen -t ed25519 -C "your_email@example.com"and rename it (e.g.
id_ed25519_github) to distinguish it from other keys.change the ssh config
1
vi .ssh/configto point the right key
1
2
3Host github-repo
HostName github.com
IdentityFile=/home/dyliu/.ssh/id_ed25519_githubuse alternative way to pull or push repo
1
git push git@github-repo:yourname/your-repo.git
Reference
https://docs.github.com/en/enterprise-cloud@latest/authentication/connecting-to-github-with-ssh/managing-deploy-keys
https://docs.github.com/en/enterprise-cloud@latest/authentication/connecting-to-github-with-ssh/using-ssh-agent-forwarding
Fix git push failure
https://dyliu0312.github.io/blog.github.io/2025/02/09/Fix-git-push-fail/