Tuesday, July 21, 2015

HGGIT errors pushing to Github

If you're using the hggit extension of mercurial (hg), and you get the error

pushing to git+https://github.com/username/project.git
http authorization required for https://github.com/username/project.git/info/refs
realm: GitHub
 searching for changes
adding objects
URLError: [Errno 10054] An existing connection was forcibly closed by the remote host

after trying to push to a cloned repository, the problem is probably your URL (even though it seems to connect and authenticate fine). For some reason certain files are inaccessible (In git you'd get: error: The requested URL returned error: 403 Forbidden while accessing https://github.com/username/project.git/info/refs). To fix this you should add your username to the url:

git+https://username@github.com/username/project.git

This would work under git, BUT, this doesn't work with hggit for some reason. It gives:

URLError: [Errno 11003] getaddrinfo failed

That means our only alternative is to use SSH, and with github, you're required to use public/private keys. These need to be generated and can be set here in github. In windows/putty, here's good info on generating them. Then they can be used by default in mercurial by adding an entry in the mercurial config files:

[ui]
ssh = tortoiseplink.exe -ssh -i "C:\Users\UserName\mykey.ppk"

Hopefully you should now be able to connect using SSH and push changes to the repo. The whole thing falls under the category of "should be easy but isn't."

No comments:

Post a Comment