There are two options to clone a git repository from github: git over ssh or https.
Cloning via https requires either your github login credentials or a github access token in $HOME/.gitconfig
. When using git over ssh you authenticate with your ssh key.
By default, go uses https to clone repositories from github when you run e.g. go get github.com/kubernetes/kubernetes
. So for cloning private repositories that means I somehow had to authenticate with github in a way I described above. The same was necessary to push into any repository (public or private).
What I ended up most of the time was either cloning my private repositories manually (via git over ssh) or manually changing the remote locations of repositories I downloaded via go get
to use git over ssh. I was not satisfied with either options so I was extra happy when I was told about this little bit you can put in $HOME/.gitconfig
:
[url "git@github.com:"]
insteadOf = https://github.com/
With this configuration, every time you clone something from a repository starting with https://github.com/
git automatically uses git@github.com:
instead.