Git克隆故障:STS/SourceTree提示认证不支持,多方案尝试无效求指导
Hey there, let's tackle this frustrating issue—since Git Bash clones just fine, the problem almost certainly lies in how STS and SourceTree are handling authentication or connection settings. Here are some targeted fixes to try:
1. Verify GUI tools are using the correct Git configuration
Many IDEs and GUI clients ship with their own embedded Git, which might not share the same settings as your Git Bash.
- For STS: Go to
Window > Preferences > Team > Git > Configuration. Compare this with the output ofgit config --listin Git Bash. Pay close attention tocredential.helperand any HTTPS/SSH related settings. If STS uses embedded Git, manually add your PAT to its credential setup, or switch it to use your system's Git (underWindow > Preferences > Team > Git > Executable). - For SourceTree: Head to
Tools > Options > Gitand check the "Git version" field. If it's using an old embedded version, switch to your system's Git path (the same one Git Bash uses).
2. Fix HTTPS authentication with PAT
If you're using HTTPS URLs, make sure the GUI tools are properly using your Personal Access Token:
- STS: When prompted for authentication, enter your username and use your PAT as the password. If the prompt doesn't show up, clear any cached credentials first (see step 5).
- SourceTree: Go to
Tools > Options > Authentication, click "Add", select your repository host (e.g., GitHub), choose "HTTPS" as the protocol, enter your username, and paste your PAT in the password field. Enable "Use modern authentication" if the option exists. - Add this global Git config to ensure proper credential handling:
git config --global credential.useHttpPath true
3. Validate SSH key setup
Since you generated an RSA key, double-check that the GUI tools are using it correctly:
- STS: Go to
Window > Preferences > General > Network Connections > SSH2. Under the "General" tab, click "Add Private Key" and select yourid_rsafile (usually inC:\Users\YourName\.ssh). Click "Test Connection", enter the host (e.g.,github.com), and verify it connects successfully. - SourceTree: Go to
Tools > Options > Authentication, click "Add", select "SSH" as the protocol, choose your private key file, and enter the passphrase if you set one. Ensure the public key is correctly added to your repository host's SSH settings (e.g., GitHub's "SSH and GPG keys" page).
4. Confirm clone URL matches authentication method
Mixing SSH and HTTPS URLs can cause authentication failures:
- If you're using SSH, your clone URL should look like
git@github.com:YourUsername/YourRepo.git. - If using HTTPS, it should be
https://github.com/YourUsername/YourRepo.git.
Make sure STS/SourceTree are using the same URL type that works in Git Bash.
5. Clear cached credentials
Windows Credential Manager might be storing outdated credentials that the GUI tools are trying to use:
- Open Windows Credential Manager (search for it in the Start Menu).
- Go to "Windows Credentials" and find any entries related to your repository host (e.g.,
github.com). - Delete these entries, then try cloning again in STS/SourceTree and re-enter your PAT or SSH passphrase.
6. Update Git to the latest version
Older Git versions don't support modern authentication methods (like PAT-only access required by GitHub):
- Check your Git Bash version with
git --version—if it's older than 2.28, download and install the latest version from Git's official site. - Configure STS/SourceTree to use this updated Git executable (as mentioned in step 1).
Give these steps a try one by one—usually, it's either a credential caching issue, mismatched Git configuration between CLI and GUI, or an outdated Git version causing the problem.
内容的提问来源于stack exchange,提问作者Ryuzaki

