To use <git push> on Visual Studio Code, but show "Could not read from remote repository."

I thought the answer by @codewizard was the correct one. Seems VS Code uses 'id_rsa.pub' key only, it was not using my other ssh key pair that git.exe was configured to use.(This key wasn't name id_rsa.) However after generating a new id_rsa key pair, I still got permission denied (publickey).

I Found my answer on this blog entry, seems vs code doesn't have a ssh-agent to interact with?

http://blog.alner.net/archive/2015/08/24/vs_code_with_git_ssh_keys_that_use_passphrases.aspx

The solution on the blog being

  • Open a command prompt.
  • Run "start-ssh-agent" and answer passphrase prompts.
  • Run "code" to launch VS Code from that environment.

I used git-bash
start the ssh agent: eval "$(ssh-agent -s)"
then "code" to launch VS Code

Note: As @JoshuaH points out in the comments, you can create a windows shortcut to simply the steps above. cmd /c start-ssh-agent & code

git fetch started working. However I started to get a openssh passphrase box every x minutes(untimed)

so I then rechecked the key was added again using git-bash
then "ssh-add ~/.ssh/id_rsa"
then git config --global credential.helper wincred

If you want a password prompt every time, then ignore the two previous commands and disable autofetch in VS Code's settings.
"git.autofetch": "true" in VS code settings to "git.autofetch": "false"