How do I set git remote origin correctly to work with go get -u?

1,824 views
Skip to first unread message

foo bar

unread,
May 21, 2015, 6:27:53 AM5/21/15
to golan...@googlegroups.com
Hi!

When working with GitHub repos I would like to set the git remote origin to "g...@github.com:user/repo.git" instead of "https://github.com/user/repo", but when using go get -u, I get the following error:

> $ go get -u github.com/mewmew/tmx/...
> $ cd $GOPATH/src/github.com/mewmew/tmx
> $ git remote rm origin
> $ git remote add origin g...@github.com:mewmew/tmx.git
> $ go get -u github.com/mewmew/tmx/...
> package github.com/mewmew/tmx: github.com/mewmew/tmx is a custom import path for https://github.com/mewmew/tmx, but /tmp/go/src/github.com/mewmew/tmx is checked out from g...@github.com:mewmew/tmx.git

How may I configure the local git repo to work with both "git@..." origins and go get -u?

Cheers /u

Tamás Gulácsi

unread,
May 21, 2015, 9:26:29 AM5/21/15
to golan...@googlegroups.com
git pull -u ...

Dan Kortschak

unread,
May 21, 2015, 6:54:15 PM5/21/15
to Tamás Gulácsi, golan...@googlegroups.com
At best the error printed here is uninformative (the same error is
printed when an actual custom import is defined as when there is no
specified custom import), and at worst it's bad behaviour; go get should
be able to tell when there was a custom import defined and only make
this check then.

foo bar

unread,
May 22, 2015, 7:20:04 AM5/22/15
to golan...@googlegroups.com
I seem to be unable to get _both_ go get -u and git push/pull to work simultaneously. Running "git pull -u origin master" results in the same error for subsequent calls to "go get -u"

> $ export GOPATH=/tmp/go

> $ go get -u github.com/mewmew/tmx/...
> $GOPATH/tmp/go/src/github.com/mewmew/tmx/

> $ git remote rm origin
> $ git remote add origin g...@github.com:mewmew/tmx.git
> $ git pull -u origin master
>  * branch            master     -> FETCH_HEAD
>  * [new branch]      master     -> origin/master
> Already up-to-date.
> $ git branch -a
> * master
>   remotes/origin/master

> $ go get -u github.com/mewmew/tmx/...
> package github.com/mewmew/tmx: github.com/mewmew/tmx is a custom import path for https://github.com/mewmew/tmx, but /tmp/go/src/github.com/mewmew/tmx is checked out from g...@github.com:mewmew/tmx.git


On Thu, May 21, 2015 at 3:26 PM, Tamás Gulácsi <tgula...@gmail.com> wrote:
git pull -u ...

--
You received this message because you are subscribed to a topic in the Google Groups "golang-nuts" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/golang-nuts/Zi-Kw2tbif8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Sebastien Binet

unread,
May 22, 2015, 7:39:26 AM5/22/15
to foo bar, golang-nuts
hi,

On Fri, May 22, 2015 at 1:19 PM, foo bar <fresh.g...@gmail.com> wrote:
> I seem to be unable to get _both_ go get -u and git push/pull to work
> simultaneously. Running "git pull -u origin master" results in the same
> error for subsequent calls to "go get -u"
>
>> $ export GOPATH=/tmp/go
>> $ go get -u github.com/mewmew/tmx/...
>> $GOPATH/tmp/go/src/github.com/mewmew/tmx/
>> $ git remote rm origin
>> $ git remote add origin g...@github.com:mewmew/tmx.git
>> $ git pull -u origin master
>> * branch master -> FETCH_HEAD
>> * [new branch] master -> origin/master
>> Already up-to-date.
>> $ git branch -a
>> * master
>> remotes/origin/master
>> $ go get -u github.com/mewmew/tmx/...
>> package github.com/mewmew/tmx: github.com/mewmew/tmx is a custom import
>> path for https://github.com/mewmew/tmx, but
>> /tmp/go/src/github.com/mewmew/tmx is checked out from
>> g...@github.com:mewmew/tmx.git

there are 2 ways to work around this.
a) the practical one.
$ go get -u -f ...

this will ignore the vanity import-paths.
use with care and consideration.

b) the more involved one.
$ git remote rename origin origin-rw
$ git remote add origin git://github.com/mewmew/tmx

(and then push to the origin-rw, go-get will pull/fetch from origin.)

c) bonus. (not tested)
$ git remote add origin ssh://mew...@github.com/tmx.git

-s

>
> On Thu, May 21, 2015 at 3:26 PM, Tamás Gulácsi <tgula...@gmail.com> wrote:
>>
>> git pull -u ...
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "golang-nuts" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/golang-nuts/Zi-Kw2tbif8/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> golang-nuts...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an

Adriano Soares

unread,
May 22, 2015, 9:19:55 AM5/22/15
to golan...@googlegroups.com
You can configure a separated url for git push:

# ~/.gitconfig
[url "g...@github.com/"] pushInsteadOf = https://github.com/

Sebastien Binet

unread,
May 22, 2015, 9:49:41 AM5/22/15
to Adriano Soares, golang-nuts
ah! I didn't know you could restrict to just push (I had everything over there:
https://github.com/sbinet/dot-config/blob/master/git/gitconfig#L23
and restrained from using it too much as that could either break 'go
get' or the 'github fork/clone/push model'...)

-s
Reply all
Reply to author
Forward
0 new messages