Visual Studio Code always asking for git credentials

后端 未结 22 634
悲&欢浪女
悲&欢浪女 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!

    0 讨论(0)
  • 2020-11-29 15:08

    I solved a similar problem in a simple way:

    1. Go To CMD or Terminal
    2. Type git pull origin master. Replace 'origin' with your Remote name
    3. It will ask for the credentials. Type it.

    That's all. I Solved the problem

    0 讨论(0)
  • 2020-11-29 15:09

    apart from adding the ssh config entries above

    if windows

    Set-Service ssh-agent -StartupType Automatic 
    

    in powershell now the vs code should not prompt...

    0 讨论(0)
  • 2020-11-29 15:11

    You should be able to set your credentials like this:

    git remote set-url origin https://<USERNAME>:<PASSWORD>@bitbucket.org/path/to/repo.git
    

    You can get the remote url like this:

    git config --get remote.origin.url
    
    0 讨论(0)
  • 2020-11-29 15:12

    In general, you can use the built-in credential storage facilities:

    git config --global credential.helper store

    Or, if you're on Windows, you can use their credential system:

    git config --global credential.helper wincred

    Or, if you're on MacOS, you can use their credential system:

    git config --global credential.helper osxkeychain

    The first solution is optimal in most situations.

    0 讨论(0)
  • 2020-11-29 15:12

    Solve the issue by following steps.

    Uninstalled softwares Vscode and git and reinstalled the same. Changed the git repository clone url from ssh to https.

    0 讨论(0)
提交回复
热议问题