I can push to git@github.com:wting/repo.git links without a password prompt since it's using my ssh-agent. However when I push to https://github.com/wting/repo.git it always asks for username and password.

The issue can somewhat be alleviated by using password caching, but I'd rather not use that.

This mainly pops up when using gists because they only show an https link (e.g. https://gist.github.com/123.git). I don't want to modify the URL of every gist I clone to use the git@gist.github.com:123.git version.

How do I set it up so that git uses my ssh-agent when pushing to an https address?

Relevant URL: Why does GitHub recommend HTTPS over SSH?


I've resorted to writing a git wrapper function:

function gc {
    if [[ ${1} =~ "github.com" ]] && [[ ${1} =~ "https" ]]; then
        git clone ${${1/https:\/\//git@}/\//:} ${@:2}
        git clone ${@}

Set it in your GitHub account.

According to your own link it seems unsupported, I guess you could write a small function in .bashrc to rewrite the remotes in git style.

  • I already have the SSH keys added to my account. I'm asking how to get it working with https links and not just git@github.com links. – wting Jan 19 '13 at 17:22
  • Why not just use the Git link? Gists might not support R+W access... – Tom Wijsman Jan 19 '13 at 17:25
  • Gists do support r+w access, but only the https link is shown. I would rather not have to modify the clone link every time I clone a gist. – wting Jan 19 '13 at 17:27
  • @WilliamTing: Oh right, just checked and works here. I believe this to be a local problem and thus not related to GitHub, please double check your configuration and follow the relevant steps again... Is there a firewall in the way? – Tom Wijsman Jan 19 '13 at 17:29
  • You can push to https using ssh-agent? There's no firewall in the way. – wting Jan 19 '13 at 17:31
  1. put your public key to github.com
  2. use ssh -T git@github.com to identify if public key works
  3. under your repo ,git remote set-url origin git@github.com:<user>/<project>.git
  4. git push

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.