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 is now set to: <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