Using Go with a private Github and forks

At Vena we use a private GitHub Enterprise instance. Recently the Infrastructure team has been using Go and we want to version our Go code there. There were two problems to overcome:

How to use private git repositories

go get will not fetch Go code from Github using the SSH transport (i.e. go get To work around this, you must first clone the repository manually:

$ cd $GOPATH/src/
$ git clone

How to work with GitHub forks

If org/repo.git uses Go sub-packages:

import (

And you create a fork of org/repo.git to your user (at
user/repo.git), you can’t clone your fork and work on that clone – the path will be $GOPATH/src/ and the above import won’t work. Go uses a structured directory hierarchy that restricts where files can be located.

To work with your fork with Go, you have to clone the original repository, and then set up your fork as the origin:

$ cd $GOPATH/src/
$ git clone
$ cd repo/
$ git remote rename origin upstream
$ git remote add origin

This way, you can work on your fork, push branches to your fork, and create pull requests to the upstream, without any issues.

Posted by James MacMahon

Technical team lead at Vena