使用Atlassian SourceTree拉取Gitee项目时认证失败求助
I’ve run into this exact issue with Gitee and SourceTree before—most of the time it’s tied to credential problems, especially since Gitee has phased out plain account passwords for HTTPS authentication (this is mandatory if you have two-factor authentication enabled). Here are the actionable steps to fix this:
Use a Gitee Personal Access Token instead of your account password
- Go to your Gitee account settings, then navigate to Personal Access Tokens under the "Security" section.
- Generate a new token with at least the
repopermission (this grants access to clone and manage your repositories). - When SourceTree prompts for authentication, enter your Gitee username as the "Username" and the generated token as the "Password".
Clear outdated saved credentials
- If SourceTree has stored old or incorrect credentials, it will keep reusing them instead of your new token:
- On Windows: Open Credential Manager → Go to "Windows Credentials" → Find entries linked to
gitee.comorgit.oschina.netand delete them. - On Mac: Open Keychain Access → Search for
gitee.com→ Remove any saved passwords/credentials for this domain.
- On Windows: Open Credential Manager → Go to "Windows Credentials" → Find entries linked to
- Restart SourceTree and try cloning again, entering your username and token when prompted.
- If SourceTree has stored old or incorrect credentials, it will keep reusing them instead of your new token:
Double-check the repository URL
- Confirm the URL you’re using in SourceTree is exactly
https://gitee.com/weidu23/EduInfoProj.git—Gitee repository names are case-sensitive, so even a small typo in the username or repo name can cause authentication failures.
- Confirm the URL you’re using in SourceTree is exactly
Test cloning via command line first
- To rule out SourceTree-specific issues, open your terminal and run:
git clone https://gitee.com/weidu23/EduInfoProj.git - When prompted, enter your Gitee username and personal access token. If this works, the problem is definitely with how SourceTree handles credentials, and clearing saved credentials (step 2) should resolve it.
- To rule out SourceTree-specific issues, open your terminal and run:
Manually input credentials in SourceTree
- When adding the repository, select the option to "Manually enter credentials" (if available) and input your username and token directly. Make sure the "Store credentials" box is checked so you don’t have to re-enter them repeatedly.
If none of these steps work, double-check that your Gitee account has full access to the repository (since you created it, this should be fine, but it’s worth confirming).
内容的提问来源于stack exchange,提问作者weidu23

