Skip to main content

Why is Git always asking for my credentials?

If Git prompts you for your credentials every time you try to interact with GitHub, you're probably using the HTTPS clone URL for your repository.

Using an HTTPS remote URL has some advantages compared with using SSH. It's easier to set up than SSH, and usually works through strict firewalls and proxies. However, it also prompts you to enter your GitHub credentials every time you pull or push a repository.

当 Git 提示你输入密码时,请输入你的personal access token。 或者,可以使用 Git 凭据管理器等凭据帮助程序。 Git 的基于密码的身份验证已被删除,取而代之的是更安全的身份验证方法。 有关详细信息,请参阅“管理个人访问令牌”。

You can avoid being prompted for your password by configuring Git to cache your credentials for you. Once you've configured credential caching, Git automatically uses your cached personal access token when you pull or push a repository using HTTPS.

If you are an Enterprise Managed User, and your enterprise owners do not have the SSO Redirect setting enabled for the enterprise, then credential caching may not work properly when using Git Credential Manager (GCM). You will need to disable GCM account filtering locally in this situation to prevent getting prompted for authentication each time you perform a Git operation. For more details, see 在 Git 中缓存 GitHub 凭据.

Further reading