简体   繁体   English

无法通过VSCode在GitHub上推送到远程SSH存储库

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

I already updated my Git for Windows. 我已经更新了Windows版Git。 I checked the keys are correct. 我检查了键是否正确。 The only "solution" is to start 唯一的“解决方案”是开始

ssh-agent

Or opening VSCode via Git Bash. 或通过Git Bash打开VSCode。

So, any useful solution? 那么,有什么有用的解决方案吗?

Log: 日志:

> git push origin master:master
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Force push might be disabled on the master branch. 在master分支上可能禁用了强制推送。 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. 如果未禁用对主服务器强制推入,则需要确保已在ssh配置中添加了ssh密钥路径,这样就不必每次都将ssh密钥添加到会话中。 Edit the config file at ~/.ssh/config and add the below (on MacOS) ~/.ssh/config编辑config文件,并添加以下内容(在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. 对于Windows,请检查我的SO答案以了解如何将ssh密钥添加到ssh配置。

UPDATE 更新

Looks like there's an open issue with VS Code on Windows here . 看起来像有一个悬而未决的问题与VS代码在Windows 这里 You may try the workaround that is mentioned here . 您可以尝试此处提到的解决方法。

您可以使用访问令牌( 在Github中 )设置远程原点例如:
git remote set-url origin https://XXXX-YOUR-ACCESS-TOKEN-XXXXXX@github.com/your-account/your-repo.git

There are many ways you can make your ssh key (with a passphrase) works in the gitbash terminal for VS Code. 在VS Code的gitbash终端中,有很多方法可以使ssh密钥(带有口令)起作用。 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. 我假设您确实环顾四周,但仍然想继续使用,因为您想使用VSCode的UI。

If so, this official page tells you why : 如果是这样, 此官方页面会告诉您原因:

Basically, you'll still have to run it via git bash or via running ssh-agent . 基本上,您仍然必须通过git bash或通过运行ssh-agent来运行它。

But you can bypass the situation using putty . 但是您可以使用腻子绕过这种情况。 I didn't try it myself. 我自己没有尝试过。

Anyway : hope it'll help. 无论如何:希望会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM