Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upcmd/go: go get git@github.com instead of https:// #6968
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
minux
Dec 17, 2013
Member
you can add the following two lines to ~/.gitconfig to work around this problem:
[url "git@github.com:"]
insteadOf = https://github.com/
you can add the following two lines to ~/.gitconfig to work around this problem:
[url "git@github.com:"]
insteadOf = https://github.com/
|
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
lukescott
commented
Dec 17, 2013
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
garyburd
Dec 17, 2013
Contributor
There's an app for fixing the remote: https://github.com/nf/remotefix/blob/master/main.go
There's an app for fixing the remote: https://github.com/nf/remotefix/blob/master/main.go |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
lukescott
Dec 18, 2013
You could do a HEAD request of the URL. If it comes back as 200 OK it's public, and if it's 404 it's private. When trying to `go get` a non-existent repo it creates the directory anyway. Github also has an REST API that could be used: http://developer.github.com/v3/repos/#get Another option is to just have an environmental variable that toggles the behavior of go get for all github.com repos, regardless if they're public or private. Downside of that is having to enter your private key password for public repos, but you only have to do that once every so often.
lukescott
commented
Dec 18, 2013
You could do a HEAD request of the URL. If it comes back as 200 OK it's public, and if it's 404 it's private. When trying to `go get` a non-existent repo it creates the directory anyway. Github also has an REST API that could be used: http://developer.github.com/v3/repos/#get Another option is to just have an environmental variable that toggles the behavior of go get for all github.com repos, regardless if they're public or private. Downside of that is having to enter your private key password for public repos, but you only have to do that once every so often. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
lukescott
commented
Mar 4, 2014
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
gopherbot
Aug 7, 2014
Comment 8 by sam@ward.io:
I have to agree that an -ssh flag sounds great, since 'git clone' doesn't entirely replace 'go get'.
gopherbot
commented
Aug 7, 2014
|
Comment 8 by sam@ward.io: I have to agree that an -ssh flag sounds great, since 'git clone' doesn't entirely replace 'go get'. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
gopherbot
commented
Dec 8, 2014
lukescott
added
the
workingasintended
label
Dec 8, 2014
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
kodabb
Dec 24, 2014
I would like to reopen this bug after the transfer from https://code.google.com/p/go/issues/detail?id=6968
I believe that the comments have not been fully addressed, and although appreciating the developers' work, the "it's not a bug, it's a feature" answer does not fully resolve the issue at hand.
This is a serious limitation of the usefulness of 'go get' especially when non-devs need to update go dependencies and when devs need to use enterprise github.
kodabb
commented
Dec 24, 2014
|
I would like to reopen this bug after the transfer from https://code.google.com/p/go/issues/detail?id=6968 I believe that the comments have not been fully addressed, and although appreciating the developers' work, the "it's not a bug, it's a feature" answer does not fully resolve the issue at hand. This is a serious limitation of the usefulness of 'go get' especially when non-devs need to update go dependencies and when devs need to use enterprise github. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
This should perhaps be discussed on golang-dev. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
gabriel
Jan 12, 2015
Having trouble finding this discussion on golang-dev. Does anyone have a link to the thread?
gabriel
commented
Jan 12, 2015
|
Having trouble finding this discussion on golang-dev. Does anyone have a link to the thread? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Agree that 'working as intended' is not really an answer. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
bmhatfield
Mar 26, 2015
+1 to doing something better here. I don't think "WorkingAsIntended" is fair.
bmhatfield
commented
Mar 26, 2015
|
+1 to doing something better here. I don't think "WorkingAsIntended" is fair. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
gabriel
Apr 13, 2015
Is there a reason it wants to assume https:// and not allow git@github.com... This makes it hard to use private or writable repos (you can't use ssh keys) and are forced to (http) authenticate on every access.
If there were an option to override this error/setting for go get ... maybe go get --allow-ssh?
Is anyone on the go team using private repos? Seems like a very common use case that a lot of people are struggling with.
gabriel
commented
Apr 13, 2015
|
Is there a reason it wants to assume https:// and not allow git@github.com... This makes it hard to use private or writable repos (you can't use ssh keys) and are forced to (http) authenticate on every access. If there were an option to override this error/setting for Is anyone on the go team using private repos? Seems like a very common use case that a lot of people are struggling with. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
gonzaloserrano
commented
Apr 13, 2015
|
Closed? :_( |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
mdempsky
Apr 13, 2015
Member
cmd/go uses https:// by default because that's what github recommends: https://help.github.com/articles/which-remote-url-should-i-use/
To avoid needing to reauthenticate for every access, you can setup a Git credential helper: https://help.github.com/articles/caching-your-github-password-in-git/
If you need/want to use git@github.com instead of https://, then see Minux's initial response on the issue: #6968 (comment)
|
cmd/go uses https:// by default because that's what github recommends: https://help.github.com/articles/which-remote-url-should-i-use/ To avoid needing to reauthenticate for every access, you can setup a Git credential helper: https://help.github.com/articles/caching-your-github-password-in-git/ If you need/want to use git@github.com instead of https://, then see Minux's initial response on the issue: #6968 (comment) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
gabriel
Apr 13, 2015
Oh awesome, thanks for pointing to the git credential helper, that works.
BTW, if you do minux's suggestion you still get an error. It might have
worked in the past but not anymore?
On Mon, Apr 13, 2015 at 12:26 PM, Matthew Dempsky notifications@github.com
wrote:
cmd/go uses https:// by default because that's what github recommends:
https://help.github.com/articles/which-remote-url-should-i-use/To avoid needing to reauthenticate for every access, you can setup a Git
credential helper:
https://help.github.com/articles/caching-your-github-password-in-git/If you need/want to use git@github.com instead of https://, then see
Minux's initial response on the issue: #6968 (comment)
#6968 (comment)—
Reply to this email directly or view it on GitHub
#6968 (comment).
gabriel
commented
Apr 13, 2015
|
Oh awesome, thanks for pointing to the git credential helper, that works. BTW, if you do minux's suggestion you still get an error. It might have On Mon, Apr 13, 2015 at 12:26 PM, Matthew Dempsky notifications@github.com
|
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
mdempsky
Apr 13, 2015
Member
I don't think so. I just verified, and Minux's suggestion works fine for me with Git 2.2 on Ubuntu 14.04. I also regularly use similar insteadOf configs to work with Go code in private (non-GitHub) Git repos.
You can also try running:
git config --global url.git@github.com:.insteadOf https://github.com/
instead of manually editing your .gitconfig file. If that still doesn't work for you, I suggest following up with the Git developers.
|
I don't think so. I just verified, and Minux's suggestion works fine for me with Git 2.2 on Ubuntu 14.04. I also regularly use similar insteadOf configs to work with Go code in private (non-GitHub) Git repos. You can also try running:
instead of manually editing your .gitconfig file. If that still doesn't work for you, I suggest following up with the Git developers. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
gonzaloserrano
Apr 14, 2015
Hi,
I ended up doing this, which is to use SSH for my company's repositories.
[url "git@github.com:mycompanyname"]
insteadOf = https://github.com/mycompanyname
Thanks guys.
gonzaloserrano
commented
Apr 14, 2015
|
Hi, I ended up doing this, which is to use SSH for my company's repositories.
Thanks guys. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
kodabb
Apr 14, 2015
Although the workaround exists, I think I and a lot of people here would appreciate to have it supported officially. Also adding a flag to a command is simpler than editing a gitconfig file in various deployment scenarios.
kodabb
commented
Apr 14, 2015
|
Although the workaround exists, I think I and a lot of people here would appreciate to have it supported officially. Also adding a flag to a command is simpler than editing a gitconfig file in various deployment scenarios. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
bradfitz
Apr 14, 2015
Member
Also adding a flag to a command is simpler
Adding a flag increases complexity, documentation requirements, and mental overhead trying to read the docs. We try really hard to avoid flags, options, and complexity.
than editing a gitconfig file in various deployment scenarios.
You should not be using go get in deployment.
Adding a flag increases complexity, documentation requirements, and mental overhead trying to read the docs. We try really hard to avoid flags, options, and complexity.
You should not be using |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
gonzaloserrano
Apr 14, 2015
You should not be using go get in deployment.
What would you use in that case? Just wondering :)
gonzaloserrano
commented
Apr 14, 2015
What would you use in that case? Just wondering :) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Let's move discussion to golang-nuts@. This isn't for a bug tracker. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
anacrolix
Apr 11, 2016
Contributor
Can you provide links to the discussions on golang-nuts or golang-dev?
|
Can you provide links to the discussions on golang-nuts or golang-dev? |
lukescott commentedDec 16, 2013
What steps will reproduce the problem? 1. go get github.com/user/package 2. cat $GOPATH/src/github.com/user/package/.git/config What is the expected output? [remote "origin"] url = git@github.com:user/package.git What do you see instead? [remote "origin"] url = https://github.com/user/package Please provide any additional information below. When using go get a GitHub repo's remote points to the https endpoint instead of the SSH endpoint. The result is having to enter your username and password for private repos. This can be problematic when you have multiple private repos to pull from. There should be an option for that if a repo is private git@ should be used instead of https://. That way the configured SSH certificate can be used instead.