Visual Studio Code always asking for git credentials

后端 未结 22 636
悲&欢浪女
悲&欢浪女 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:30

    After fighting with something like this for a little while, I think I came up with a good solution, especially when having multiple accounts across both GitHub and BitBucket. However for VSCode, it ultimately ended up as start it from a Git Bash terminal so that it inherited the environment variables from the bash session and it knew which ssh-agent to look at.

    I realise this is an old post but I still really struggled to find one place to get the info I needed. Plus since 2017, ssh-agent got the ability to prompt you for a passphrase only when you try to access a repo.

    I put my findings down here if anyone is interested:

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

    This has been working for me:
    1. Set credential hepler to store
    $ git config --global credential.helper store
    2. then verify if you want:
    $ git config --global credential.helper store

    Simple example when using git bash quoted from Here (works for current repo only, use --global for all repos)

    $ git config credential.helper store
    $ git push http://example.com/repo.git
    Username: < type your username >
    Password: < type your password >

    [several days later]
    $ git push http://example.com/repo.git
    [your credentials are used automatically]

    Will work for VS Code too.

    More detailed example and advanced usage here.

    Note: Username & Passwords are not encrypted and stored in plain text format so use it on your personal computer only.

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

    I managed to stop this by carrying out the following steps.

    1. Uninstall Git Desktop (Not sure this is necessary)
    2. Uninstall Credentials Manager cd "C:\Program Files\Git\mingw64\libexec\git-core" followed by git-credential-manager.exe uninstall
    3. Reset credentials helper to use wincred git config --global credential.helper wincred
    4. User VS Code to Push some changes and re-input credentials.

    NOTE: I was using a Personal Access Token as my password.

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

    You can refer this link for setup a Git Credential

    You can run the following command to save your git credentials. You no need to enter username and password every git command run. (Its for Windows)

    git config --global credential.helper wincred
    

    For Mac / Linux click on this link for How to save Git credentials

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