switching-org

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Steps

步骤

  1. Identify the org: the user provides a username or alias (
    orgIdentifier
    ). If not provided, run
    sf org list
    to show authenticated orgs and ask the user which one to use.
  2. Set the default org:
    • Local (default):
      sf config set target-org <orgIdentifier>
      • Applies only within the current project directory. Use this for normal project work.
    • Global (only if user explicitly requests):
      sf config set target-org <orgIdentifier> --global
      • Applies system-wide across all directories. Use when working outside a project or when the user asks for global scope.
    • If this fails, report the error and suggest running
      sf org login web
      if the org may not be authorized.
  3. Verify:
    • sf config get target-org --json
    • Note: the JSON output does not include a scope/location field — it cannot confirm whether the value is local or global. Confirm the value only, e.g.:
      target-org is now set to: <value>
    • If it fails, report the error and advise running
      sf config get target-org
      .
  1. 识别组织:用户提供用户名或别名(
    orgIdentifier
    )。若未提供,则运行
    sf org list
    命令显示已认证的组织,并询问用户要使用哪一个。
  2. 设置默认组织:
    • 本地(默认):
      sf config set target-org <orgIdentifier>
      • 仅在当前项目目录内生效。适用于常规项目工作场景。
    • 全局(仅当用户明确要求时使用):
      sf config set target-org <orgIdentifier> --global
      • 在系统范围内的所有目录生效。适用于在项目外工作或用户要求全局作用域的场景。
    • 若设置失败,报告错误并建议如果组织可能未授权,运行
      sf org login web
      命令。
  3. 验证:
    • 运行
      sf config get target-org --json
    • 注意:JSON输出不包含作用域/位置字段——无法确认该值是本地还是全局的。仅确认值本身,例如:
      target-org 现已设置为:<value>
    • 若验证失败,报告错误并建议运行
      sf config get target-org
      命令。

Notes

注意事项