Visual Studio Code always asking for git credentials

后端 未结 22 699
悲&欢浪女
悲&欢浪女 2020-11-29 14:50

I started using Visual Studio Code, and I was trying to save my test project into GitHub, but Visual Studio Code is always asking for my GitHub credentials.

I have i

22条回答
  •  醉梦人生
    2020-11-29 15:06

    The following steps walk you through how to:

    1. Generate SSH keys (without passphrase**)
    2. Add the public key generated in step 1 to your Git repository
    3. Confirm the above steps have been completed successfully
    4. Make your first commit (without having to provide a username / password)

    **Generating SSH keys without a passphrase is unwise if your work is particularly sensitive.

    OS - Fedora 28 | Editor - VS Code v1.23.0 | Repository - Git

    Generate SSH keys:

    • ssh-keygen -t rsa -C "email@goeshere.com"
    • Enter file in which to save the key: Press Enter
    • Enter passphrase: Press Enter
    • Enter same passphrase again: Press Enter

    After completing the above steps, the location of your public key is shown in the terminal window. If the currently logged in user is 'bob' the location of your public key would be /home/bob/.ssh/id_rsa.pub

    Copy and import public key to GitHub:

    • cat /home/bob/.ssh/id_rsa.pub

    • Copy the whole public key that is now displayed in your terminal window to the clipboard

    • Go to https://github.com and sign in
    • Click the user icon in the top right corner of the screen and select Settings
    • Click SSH and GPG keys
    • Click New SSH key
    • Enter a title, paste the public key copied to the clipboard in the first bullet point, and click Add SSH key

    Confirm the above steps:

    • ssh -T git@github.com

    • yes

    • Hi ! You've successfully authenticated, but GitHub does not provide shell access.

    First commit / push without having to enter a username / password: - touch test.txt

    • git add test.txt

    • git commit - opens editor, enter a message and save the file. If vi is your editor, press i once the file opens, enter a message, press esc, and then enter :x to save changes.

    • git push

    The only hiccup you may encounter is when you attempt to SSH to GitHub. This link will provide some assistance -

    • https://help.github.com/articles/error-agent-admitted-failure-to-sign/

    Happy hunting!

提交回复
热议问题