technicalpickles/homesick

Clone SSH URLs by default

nomicode opened this issue · 6 comments

If you do this:

homesick clone nslater/dotfiles

Homesick clones using the HTTPS URL, meaning that if you homesick cd dotfiles, make some changes, and then try to push, you will be prompted for your password. (Assuming you as using SSH keys for authentication with GitHub.)

If you do this:

homesick clone git://github.com/nslater/dotfiles.git

And try the same, you actually get this:

fatal: remote error: 
  You can't push to git://github.com/nslater/dotfiles.git
  Use https://github.com/nslater/dotfiles.git

What I actually needed to do was:

homesick clone git@github.com:nslater/dotfiles.git

That works perfectly when you make changes from within your homesick dir.

I think this is important because I make all of my changes inside the homesick dir, because it saves a push, fetch, and rebase cycle between my main checkout, and the homesick clone. But it's frustrating that the default two documented methods produce a local clone that either prompts me for my password, or doesn't let me push.

Cloning over https is generally preferred. If you are getting constantly prompted for a password when using it, check out https://help.github.com/articles/set-up-git#password-caching for info on fixing it.

That said, it might make sense to have a homesick configuration option to prefer https or ssh.

Oh, I thought SSH was preferred!

@technicalpickles why do you say https is preferred? For example github itself show "SSH clone URL" by default in clone widget. I have keys configured with passphrase and everything. Why should I enter my password? Now I need to go to .homesick and change remote to make it work using settings I already have.

@soswow The default authentication method for the clone widget is HTTPS, but if you click SSH it will remember your preference. In GitHub's Set Up Git tutorial, they give instructions for HTTPS, noting:

Tip: The credential helper only works when you clone an HTTPS repository URL. If you use the SSH repository URL instead, SSH keys are used for authentication. This guide offers help generating and using an SSH key pair.

Instead of using SSH authentication, GitHub's preferred authentication method is git's built-in gitcredentials feature, although they allow SSH instead. As @technicalpickles said earlier:

It might make sense to have a homesick configuration option to prefer https or ssh.

But, to my knowledge, this feature hasn't been worked on yet. Please let me know if there are any other questions that I can answer!

I don't know if things have changed since this issue was opened, but currently the "set up git" page that technicalPickles linked to lists SSH as the recommended method over HTTPS

I'm going to close this due to the age and the lack of direction on whether SSH or HTTPS is really preferred. Feel free to reopen as needed.