1
0
mirror of https://github.com/golang/go synced 2024-11-11 22:10:22 -07:00

doc: update "go get" HTTPS answer to mention .netrc

The existing text makes it seem like there's no way
to use GitHub over HTTPS. There is. Explain that.

Also, the existing text suggests explicit checkout into $GOPATH,
which is not going to work in the new module world.
Drop that alternative.

Also, the existing text uses pushInsteadOf instead of insteadOf,
which would have the effect of being able to push to a private
repo but not clone it in the first place. That seems not helpful,
so suggest insteadOf instead.

Fixes #18927.

Change-Id: Ic358b66f88064b53067d174a2a1591ac8bf96c88
Reviewed-on: https://go-review.googlesource.com/107775
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Russ Cox 2018-04-18 10:45:52 -04:00
parent e9bc0c5d24
commit 09d36a819e

View File

@ -1097,24 +1097,27 @@ The <code>go get</code> command therefore uses HTTPS for safety.
</p>
<p>
If you use <code>git</code> and prefer to push changes through SSH using your existing key
it's easy to work around this. For GitHub, try one of these solutions:
<code>Git</code> can be configured to authenticate over HTTPS or to use SSH in place of HTTPS.
To authenticate over HTTPS, you can add a line
to the <code>$HOME/.netrc</code> file that git consults:
</p>
<ul>
<li>Manually clone the repository in the expected package directory:
<pre>
$ cd src/github.com/username
$ git clone git@github.com:username/package.git
machine github.com login <i>USERNAME</i> password <i>APIKEY</i>
</pre>
</li>
<li>Force <code>git push</code> to use the <code>SSH</code> protocol by appending
these two lines to <code>~/.gitconfig</code>:
<p>
For GitHub accounts, the password can be a
<a href="https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/">personal access token</a>.
</p>
<p>
<code>Git</code> can also be configured to use SSH in place of HTTPS for URLs matching a given prefix.
For example, to use SSH for all GitHub access,
add these lines to your <code>~/.gitconfig</code>:
</p>
<pre>
[url "git@github.com:"]
pushInsteadOf = https://github.com/
[url "ssh://git@github.com/"]
insteadOf = https://github.com/
</pre>
</li>
</ul>
<h3 id="get_version">
How should I manage package versions using "go get"?</h3>