Skip to main content

Authenticating to GitHub

You can securely access your account's resources on GitHub Desktop by authenticating to GitHub.

About authentication

To keep your account secure, you must authenticate before you can use GitHub Desktop to access resources on GitHub.

Before you authenticate, 您必须已经在 GitHub.com 上拥有帐户。

  • 有关在 GitHub.com 上创建帐户的更多信息,请参阅“注册新 GitHub 帐户”。
  • 对于 GitHub Enterprise 帐户,请联系您的 GitHub Enterprise 网站管理员。

Authenticating an account on GitHub

  1. 在菜单栏中,使用 GitHub Desktop 下拉菜单,然后单击 Preferences(首选项)GitHub Desktop 下拉菜单中的首选项值

  2. 在 Preferences(首选项)窗口中,选择 Accounts(帐户)Preferences(首选项)窗口中的 Accounts(帐户) 窗格

  3. To the right of "GitHub.com," click Sign In. The Sign In button for GitHub

  4. In the "Sign in Using Your Browser" pane, click Continue With Browser. GitHub Desktop 将打开您的默认浏览器。 使用浏览器链接登录

  5. 要验证 GitHub,请输入您的 GitHub.com 凭据,然后单击 Sign in(登录)浏览器中 GitHub 的登录按钮

    或者,如果您已登录 GitHub,请按照提示返回 GitHub Desktop 完成身份验证。

  6. 如果已为 GitHub 配置双重身份验证 (2FA),请执行以下操作之一:

    • 如果通过 SMS 设置 2FA,则从 SMS 消息检索 2FA 代码 。
    • 如果使用 TOTP 应用程序设置 2FA,则生成 2FA 代码。

    然后在 GitHub 上出现提示时输入 2FA 码,再单击 Verify(验证)2FA 验证码字段

  7. After GitHub authenticates your account, follow the prompts to return to GitHub Desktop.

Authenticating an account on GitHub Enterprise Server

  1. 在菜单栏中,使用 GitHub Desktop 下拉菜单,然后单击 Preferences(首选项)GitHub Desktop 下拉菜单中的首选项值

  2. 在 Preferences(首选项)窗口中,选择 Accounts(帐户)Preferences(首选项)窗口中的 Accounts(帐户) 窗格

  3. 在“GitHub Enterprise Server”右边单击 Sign In(登录)GitHub Enterprise Server 的 Sign in(登录)按钮

  4. To add an account on 您的 GitHub Enterprise Server 实例, type the URL for your instance under "Enterprise address," then click Continue. The Sign In button for GitHub Enterprise

  5. In the "Sign in Using Your Browser" pane, click Continue With Browser. GitHub Desktop 将打开您的默认浏览器。 使用浏览器链接登录

  6. To authenticate to 您的 GitHub Enterprise Server 实例 account, type your account credentials and click Sign in. The Sign In button for GitHub Enterprise Server in browser

    Alternatively, if you were already signed in to 您的 GitHub Enterprise Server 实例 account, follow the prompts to return to GitHub Desktop to finish authenticating.

Authenticating an account on GitHub

  1. 使用 File(文件)菜单,然后单击 Options(选项)Settings(设置)下拉菜单中的 Options(选项)值

  2. 在 Options(选项)窗口中,选择 Accounts(帐户)Options(选项)窗口中的 Accounts(帐户)窗格

  3. To the right of "GitHub.com," click Sign in. The Sign In button for GitHub

  4. In the "Sign in Using Your Browser" pane, click Continue With Browser. GitHub Desktop 将打开您的默认浏览器。 使用浏览器链接登录

    警告:不支持使用用户名和密码向 GitHub 验证。 我们要求使用浏览器进行身份验证。

  5. 要验证 GitHub,请输入您的 GitHub.com 凭据,然后单击 Sign in(登录)浏览器中 GitHub 的登录按钮

    或者,如果您已登录 GitHub,请按照提示返回 GitHub Desktop 完成身份验证。

  6. 如果已为 GitHub 配置双重身份验证 (2FA),请执行以下操作之一:

    • 如果通过 SMS 设置 2FA,则从 SMS 消息检索 2FA 代码 。
    • 如果使用 TOTP 应用程序设置 2FA,则生成 2FA 代码。

    然后在 GitHub 上出现提示时输入 2FA 码,再单击 Verify(验证)2FA 验证码字段

  7. After GitHub authenticates your account, follow the prompts to return to GitHub Desktop.

Authenticating an account on GitHub Enterprise

  1. 使用 File(文件)菜单,然后单击 Options(选项)Settings(设置)下拉菜单中的 Options(选项)值

  2. 在 Options(选项)窗口中,选择 Accounts(帐户)Options(选项)窗口中的 Accounts(帐户)窗格

  3. 在“GitHub Enterprise Server”右边单击 Sign In(登录)GitHub Enterprise Server 的 Sign in(登录)按钮

  4. To add a GitHub Enterprise account, type your credentials under "Enterprise address," then click Continue. The Sign In button for GitHub Enterprise

  5. 如果已为 GitHub Enterprise 配置双重身份验证,请执行以下操作之一:

    • 如果通过 SMS 设置 2FA,则从 SMS 消息检索 2FA 代码 。
    • 如果使用 TOTP 应用程序设置 2FA,则生成 2FA 代码。

    然后在 GitHub Desktop 上出现提示时输入 2FA 码,再单击 Sign In(登录)2FA 验证码字段

Troubleshooting authentication issues

If GitHub Desktop encounters an authentication error, you can use error messages to troubleshoot.

If you encounter an authentication error, first try signing out and signing back in to your account on GitHub Desktop.

For some errors, GitHub Desktop will prompt you with an error message. If you are not prompted, or to find more information about any error, view the GitHub Desktop log files by using the following steps.

  1. Use the Help drop-down menu and click Show Logs in Finder. The Show Logs in Finder button
  2. Select the log file from the date when you encountered the authentication error.
  1. Use the Help drop-down menu and click Show Logs in Explorer. The Show Logs in Explorer button
  2. Select the log file from the date when you encountered the authentication error.

Review the troubleshooting information below for the error message that you encounter.

Bad credentials

Error: Bad credentials

This error means that there is an issue with your stored account credentials.

To troubleshoot, sign out of your account on GitHub Desktop and then sign back in.

Empty token

info: [ui] [AppStore.withAuthenticatingUser] account found for repository: node -  (empty token)

This error means that GitHub Desktop is unable to find the access token that it created in the system keychain.

To troubleshoot, sign out of your account on GitHub Desktop and then sign back in.

Repository not found

fatal: repository 'https://github.com//.git' not found

(The error was parsed as 8: The repository does not seem to exist anymore. You may not have access, or it may have been deleted or renamed.)

This error means that you do not have permission to access the repository that you are trying to clone.

To troubleshoot, contact the person in your organization who administers permissions.

Could not read from remote repository

git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

This error means that you do not have a valid SSH key set up.

To troubleshoot, see "Generating a new SSH key and adding it to the SSH agent."

Failed to clone

fatal: clone of 'git@github.com:/' into submodule path '' failed
Failed to clone 'src/github.com//'. Retry scheduled
Cloning into ''...
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

This error means that either the repository that you are trying to clone has submodules that you do not have access to or you do not have a valid SSH key set up.

If you do not have access to the submodules, troubleshoot by contacting the person who administers permissions for the repository.

If you do not have a valid SSH key set up, see "Generating a new SSH key and adding it to the SSH agent."

Unable to read AskPass response

error: unable to read askpass response from '/Users//GitHub Desktop.app/Contents/Resources/app/static/ask-pass-trampoline.sh'
fatal: could not read Username for 'https://github.com': terminal prompts disabled

This error can be caused by multiple events.

If the Command Processor registry entries are modified, GitHub Desktop will respond with an Authentication failed error. To check if these registry entries have been modified, follow these steps.

  1. Open the Registry Editor (regedit.exe) and navigate to the following locations. HKEY_CURRENT_USER\Software\Microsoft\Command Processor\ HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor\
  2. Check to see if there is an Autorun value in either location.
  3. If there is an Autorun value, delete it.

If your Windows username has extended Unicode characters, it may cause an AskPass response error. To troubleshoot, create a new Windows user account and migrate your files to that account. For more information, see "Create a user account in Windows" in the Microsoft documentation.

Further reading