{"meta":{"title":"为什么 Git 总是要求我提供凭据？","intro":"如果您在每次尝试与 GitHub 交互时，Git 都会提示输入凭据，很可能是因为您使用了存储库的 HTTPS 克隆 URL。","product":"开始","breadcrumbs":[{"href":"/zh/enterprise-server@3.22/get-started","title":"开始"},{"href":"/zh/enterprise-server@3.22/get-started/git-basics","title":"Git 基本知识"},{"href":"/zh/enterprise-server@3.22/get-started/git-basics/why-is-git-always-asking-for-my-credentials","title":"重复凭据提示"}],"documentType":"article"},"body":"# 为什么 Git 总是要求我提供凭据？\n\n如果您在每次尝试与 GitHub 交互时，Git 都会提示输入凭据，很可能是因为您使用了存储库的 HTTPS 克隆 URL。\n\n与使用 SSH 相比，使用 HTTPS 远程 URL 具有一些优势。 它比 SSH 更容易设置，通常通过严格的防火墙和代理进行工作。 但是，每次拉取或推送仓库时，它也会提示你输入 GitHub 凭据。\n\n当 Git 提示输入密码时，请输入你的 personal access token密码。 或者，可以使用 [Git 凭据管理器](https://github.com/GitCredentialManager/git-credential-manager/blob/main/README.md)等凭据帮助程序。 Git 的基于密码的身份验证已被删除，取而代之的是更安全的身份验证方法。 有关详细信息，请参阅“[管理个人访问令牌](/zh/enterprise-server@3.22/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens)”。\n\n可以通过将 Git 配置为[自动缓存凭据](/zh/enterprise-server@3.22/get-started/git-basics/caching-your-github-credentials-in-git)，避免提示输入密码。 在配置凭据缓存后，当你使用 HTTPS 拉取或推送存储库时，Git 自动使用缓存的 personal access token。\n\n## 延伸阅读\n\n* [关于远程仓库](/zh/enterprise-server@3.22/get-started/git-basics/about-remote-repositories)\n* [关于 GitHub 的身份验证](/zh/enterprise-server@3.22/authentication/keeping-your-account-and-data-secure/about-authentication-to-github)\n* [生成新的 SSH 密钥并将其添加到 ssh-agent](/zh/enterprise-server@3.22/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#adding-your-ssh-key-to-the-ssh-agent)\n* [在 Git 中缓存GitHub凭据](/zh/enterprise-server@3.22/get-started/git-basics/caching-your-github-credentials-in-git)"}