简体   繁体   中英

How do I switch Github Push/Pull from user/pass to SSH in VS Code

I got an email from Github saying that they are deprecating user/pass authentication for git operations next summer. user/pass was what was using inside VSCode to push/pull.

I set up my SSH and added it to my github account. And I can connect from the command line properly:

sean@sean-ThinkPad-T480:~/.ssh$ ssh -T git@github.com
Hi seanrasmussen! You've successfully authenticated, but GitHub does not provide shell access.

However, when I push/pull with VSCode's GUI, I think it is still using the old way. Not SSH. How do I force SSH instead in the VSCode GUI?

Thanks!

This has nothing to do with VS Code. The URL of the remote repository is stored in your local repository.

  1. Open a command-line/shell and cd to your code.

  2. Then, check the current remote URL:

    git remote -v

    The result looks probably similar to this:

> origin  https://github.com/YOUR_GIHUB_USERNAME/YOUR_REPO_NAME.git (fetch)
> origin  https://github.com/YOUR_GIHUB_USERNAME/YOUR_REPO_NAME.git (push)
  1. Change the URL to ssh:

    git remote set-url origin git@github.com:YOUR_GIHUB_USERNAME/YOUR_REPO_NAME.git

  2. (optionally) Check the remote URL again (it should now return the new URL):

    git remote -v

Now git will fetch/pull from/push to this new URL. This includes any git integrations into editors, IDEs, or git GUI clients.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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