Can't seem to push to GitHub using magit

折月煮酒 提交于 2019-12-05 08:38:14

user.name is only for authorship of commits, and not used for authentication. I wonder how you got this idea, given that no such feature is documented.

The username for authentication must be set explicitly, via git-credentials. In case of Github, add the following to your Git configuration:

[credential "https://github.com"]
    username = johndoe

Where johndoe is to be replaced with your real user name, obviously.

I'd recommend you to use SSH, though. Generate an SSH keypair, add the public key to Github, and use git@github.com:johndoe/myrepo.git instead of https://github.com/johndoe/myrepo.git as remote. Together with Putty's auth agent, you'll be able to push without any further password prompts after adding your key once to the agent.

You'll also be able to use different keys for different systems, and revoke each key independently from others, and from your Github password. Furthermore, SSH keys cannot be used to login on Github itself, so even if your keys get lost your Github account is still mostly safe. All in all, SSH keys are much safer, especially on systems that are at a risk of getting lost or stolen, e.g. laptops.

Quick fix:

(setenv "GIT_ASKPASS" "git-gui--askpass")

Check this: https://github.com/magit/magit/wiki/FAQ#windows-cannot-push-via-https

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!