switching-org
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSteps
步骤
- Identify the org: the user provides a username or alias (). If not provided, run
orgIdentifierto show authenticated orgs and ask the user which one to use.sf org list - 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 if the org may not be authorized.
sf org login web
- Local (default):
- 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
- 识别组织:用户提供用户名或别名()。若未提供,则运行
orgIdentifier命令显示已认证的组织,并询问用户要使用哪一个。sf org list - 设置默认组织:
- 本地(默认):
sf config set target-org <orgIdentifier>- 仅在当前项目目录内生效。适用于常规项目工作场景。
- 全局(仅当用户明确要求时使用):
sf config set target-org <orgIdentifier> --global- 在系统范围内的所有目录生效。适用于在项目外工作或用户要求全局作用域的场景。
- 若设置失败,报告错误并建议如果组织可能未授权,运行命令。
sf org login web
- 本地(默认):
- 验证:
- 运行
sf config get target-org --json - 注意:JSON输出不包含作用域/位置字段——无法确认该值是本地还是全局的。仅确认值本身,例如:
target-org 现已设置为:<value> - 若验证失败,报告错误并建议运行命令。
sf config get target-org
- 运行
Notes
注意事项
- Unified CLI uses keys like and
target-org. Legacy sfdx keys (target-dev-hub,defaultusername) are deprecated in this context.defaultdevhubusername - The sf CLI does not have or
--localflags for config set. Local scope is the default behavior.--scope - If the org does not change after setting the config, check whether is set — environment variables override config values.
SF_TARGET_ORG - Salesforce CLI config (unified) reference: https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_config_commands_unified.htm#cli_reference_config_set_unified
- 统一CLI使用和
target-org这类键名。在此场景下,旧版sfdx的键名(target-dev-hub、defaultusername)已被弃用。defaultdevhubusername - sf CLI的config set命令没有或
--local标志。本地作用域是默认行为。--scope - 若设置配置后组织未更改,请检查是否设置了环境变量——环境变量会覆盖配置值。
SF_TARGET_ORG - Salesforce CLI配置(统一版)参考文档:https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_config_commands_unified.htm#cli_reference_config_set_unified