How to push using SSH and pull using HTTPS for all repos on GitHub?

4 messages, 2 authors, 2018-08-05 · open the first message on its own page

How to push using SSH and pull using HTTPS for all repos on GitHub?

From: Jeffrey Walton <hidden>
Date: 2018-08-04 23:16:13

I'm having trouble setting up my ~/.gitconfig to push using SSH and
pull using HTTPS for all repos on GitHub. The idea is, no passwords on
pulls and only use the password for push.

I've got the first part of the equation using the following in my
~/.gitconfig (the ellipses are user info):

   $ cat ~/.gitconfig
   ...
   # Enforce SSH
   [url "ssh://git@github.com/"]
       insteadOf = https://github.com/
   [push]
      default = current

The above pushes and pulls using SSH. Pulls only need HTTPS so I tried
adding the following which does not work as expected:

    [pull "https://github.com/"]

I've found several ways to break Git when trying to setup the HTTPS pull.

My question is, how do I setup the HTTPS pull in my ~/.gitconfig?

Thanks in advance.

Re: How to push using SSH and pull using HTTPS for all repos on GitHub?

From: Jonathan Nieder <hidden>
Date: 2018-08-05 01:26:07

Hi,

Jeffrey Walton wrote:
I'm having trouble setting up my ~/.gitconfig to push using SSH and
pull using HTTPS for all repos on GitHub. The idea is, no passwords on
pulls and only use the password for push.

I've got the first part of the equation using the following in my
~/.gitconfig (the ellipses are user info):

   $ cat ~/.gitconfig
   ...
   # Enforce SSH
   [url "ssh://git@github.com/"]
       insteadOf = https://github.com/
Does putting pushInsteadOf here work?

Thanks and hope that helps,
Jonathan

Re: How to push using SSH and pull using HTTPS for all repos on GitHub?

From: Jeffrey Walton <hidden>
Date: 2018-08-05 02:19:59

On Sat, Aug 4, 2018 at 9:26 PM, Jonathan Nieder [off-list ref] wrote:
Hi,

Jeffrey Walton wrote:
quoted
I'm having trouble setting up my ~/.gitconfig to push using SSH and
pull using HTTPS for all repos on GitHub. The idea is, no passwords on
pulls and only use the password for push.

I've got the first part of the equation using the following in my
~/.gitconfig (the ellipses are user info):

   $ cat ~/.gitconfig
   ...
   # Enforce SSH
   [url "ssh://git@github.com/"]
       insteadOf = https://github.com/
Does putting pushInsteadOf here work?
Yes, that was the trick.

Thank you very much.

Re: How to push using SSH and pull using HTTPS for all repos on GitHub?

From: Jonathan Nieder <hidden>
Date: 2018-08-05 03:28:59

Jeffrey Walton wrote:
On Sat, Aug 4, 2018 at 9:26 PM, Jonathan Nieder [off-list ref] wrote:
quoted
Jeffrey Walton wrote:
quoted
quoted
I'm having trouble setting up my ~/.gitconfig to push using SSH and
pull using HTTPS for all repos on GitHub. The idea is, no passwords on
pulls and only use the password for push.
[...]
quoted
quoted
   [url "ssh://git@github.com/"]
       insteadOf = https://github.com/
Does putting pushInsteadOf here work?
Yes, that was the trick.

Thank you very much.
You're welcome.

I should have asked: do you remember where you first looked for this
answer in documentation?  Maybe we can improve it.

A few thoughts:

 1. git-push(1) could get a CONFIGURATION section.

 2. the description of url.*.insteadOf in git-config(1) could mention
    pushInsteadOf.  The description of url.*.pushInstead is right
    after it today, but there is nothing guaranteeing that that will
    continue to be true.

 3. Likewise, the description of remote.<name>.push could include a
    pointer.

 4. Maybe there's a place to put some thoughts on this in the
    user-manual, too.  It already mentions remote.<name>.push.

What do you think?

Thanks,
Jonathan
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help