pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://docs.github.com/zh/github-cli/github-cli/using-multiple-accounts

ub-cli/using-multiple-accounts" data-next-head=""/>
Skip to main content

跨 GitHub 平台使用 GitHub CLI

了解如何在不同的 GitHub 平台上对帐户进行身份验证时运行命令。

如果你在多个 GitHub 平台上拥有帐户,例如在 GitHub.com 上拥有个人帐户,在 托管用户帐户 上拥有 GHE.com,则可以对每个帐户使用 gh auth login 进行身份验证。

你需要进行身份验证才能在给定环境中运行_任何_命令。 例如,即使你运行的命令只需要对 GitHub.com 上的公共存储库具有读取权限,但如果您仅对 GHE.com 上的帐户进行了身份验证,那么你将无法使用此命令。 因此,你应该对你想与 GitHub CLI 一起使用的所有帐户进行身份验证。

如何为每个帐户运行命令?

使用多个帐户进行身份验证后,当你运行命令时,GitHub CLI 有时可以自动检测你正在尝试访问的平台。 在其他情况下,你需要在命令中提供更多信息。

当你处于特定存储库的上下文中时,GitHub CLI 会自动识别你打算使用的帐户****。 例如,如果你使用 cd 进入你的 my-repo 目录并运行 gh repo view,该命令将针对该存储库的正确平台。

当没有这种上下文时,GitHub CLI 无法自动检测你想要使用的帐户****。 例如,如果你运行 gh repo list 来列出帐户的存储库,则 GitHub CLI 将不知道你要访问哪一个帐户。 在这样的情况下:

  • GitHub CLI 默认为 GitHub.com。
  • 可以设置 GH_HOST 环境变量来更改这些类型的请求的默认目标。 请参阅 GitHub CLI 手册中的 gh environment
  • 某些命令允许使用选项指定目标环境 --hostname ,例如 gh api,或传递存储库的完整 URL,例如 gh pr view

是否可以在同一平台上使用多个帐户?

还可以在同一平台上对多个帐户进行身份验证。 若要在这些帐户之间切换,可以使用 gh auth switch 命令。 请参阅 GitHub CLI 手册中的 gh auth switch

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy