Can't push to remote SSH repo on GitHub via VSCode

Force push might be disabled on the master branch. Check the settings on the repo that you're trying to push to.

If force push on master is not disabled, you need to make sure that you have added your ssh key path on your ssh config, so that you don't have to add the ssh key to the session every time. Edit the config file at ~/.ssh/config and add the below (on MacOS)

Host *
  UseKeychain yes
  AddKeysToAgent yes
  IdentityFile ~/path/to/key

For Windows, please check my SO answer to know how to add the ssh key to the ssh config.

UPDATE

Looks like there's an open issue with VS Code on Windows here. You may try the workaround that is mentioned here.


There are many ways you can make your ssh key (with a passphrase) works in the gitbash terminal for VS Code. I'll let you look around to find it if you didn't.

I assume you did look around and are still stuck because you want to use the UI of VSCode.

If so, this official page tells you why :

Basically, you'll still have to run it via git bash or via running ssh-agent.

But you can bypass the situation using putty. I didn't try it myself.

Anyway : hope it'll help.


You could set an remote origin using an access token (in Github) like:
git remote set-url origin https://[email protected]/your-account/your-repo.git