<p>Hoping someone can help me out - I've been banging my head against the wall...</p>
<p>I'm trying to update all the dependencies used by one of my packages hosted on github (github.com/foo/bar). This package was initially cloned using a <code>git pull</code>.</p>
<p>I can <code>git pull</code> just fine - the SSH keys, everything checks out. However, when I run <code>go get -u</code>, I get:</p>
<pre><code>github.com/foo/bar (download)
# cd C:\Users\jwcrux\go\src\github.com\foo\bar; git pull --ff-only
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
package github.com/foo/bar: exit status 1
</code></pre>
<p>I'm not sure why <code>go get</code> isn't using my SSH key to run the pull... </p>
<p>Anyone run into this before and have suggestions?</p>
<hr/>**评论:**<br/><br/>ROFLLOLSTER: <pre><p>I believe go get uses https rather than ssh and hence can only pull from public repos.</p></pre>nhooyr: <pre><p>https can pull from public repos just fine. I use it all the time.</p>
<p>edit: private.</p></pre>ROFLLOLSTER: <pre><p>I wasn't disputing that... what did you think I meant?</p></pre>nhooyr: <pre><p>oh shit, I meant private.</p></pre>ROFLLOLSTER: <pre><p>Yes I know it can pull from private repos but there's no HTTPS 'keyring' so go get doesn't have any credentials to fetch with.</p></pre>gohacker: <pre><p><code>$ git config remote.origin.url</code></p>
<p>Does it show <code>https://github.com/foo/bar</code>? Or <code>git://github.com:foo/bar</code>?</p></pre>nsd433: <pre><p>Like ROFLOLSTER says, go get passes https URLs to git when accessing remote repos. What I do is configure git to rewrite https URLs to github as ssh. In my .gitconfig I have:</p>
<pre><code>[url "git@github.com:"]
insteadOf = https://github.com/
</code></pre></pre>titpetric: <pre><p>This might not work if you're using some public repos for which obviously you don't have ssh access for. But a slightly longer insteadOf/url would fix that :)</p></pre>nsd433: <pre><p>Fetching public github repos via ssh just works. There is no problem. You can't, of course, push commits to them, but that's no different from https.</p></pre>mixedCase_: <pre><p>The best workaround IMO is creating the directories and cloning it yourself. Then you will be able to go get -u all you want.</p>
<p>Better than fiddling with Git global settings.</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传