I kept running into a problem after completely wiping my Mac and reinstalling software: I could not get Visual Studio Code to push or pull to repositories in my GitLab account. It turned out the solution was pretty easy.
Visual Studio Code uses the system git. In my case that git client was installed via Homebrew1. After installing git I neglected to generate an ssh key. More importantly, I neglected to generate the default ssh public/private keypair (files are called id_rsa.pub/id_rsa). Without any other setup this is the public/private keypair that git will use for ssh operations against a remote server.
So the key was generated with:
ssh-keygen -o -t rsa
using the defaults when prompted and not assigning a password.
I then added this key to GitLab by first doing:
pbcopy < ./id_rsa.pub
at the command line (which copies the text in the file to the system clipboard) then pasting it into the proper spot on GitLab.
- Xcode, or the Apple-provided command line tools package for developers, will also install a system-wide git client. ↩︎