Categories
sfdx

Change default DevHub in sfdx

Problem

You want to change the default DevHub org in your sfdx configuration.

% sfdx force:org:list                                                                 
=== Orgs
     ALIAS                USERNAME                         ORG ID              CONNECTED STATUS
───  ─────────────────── ───────────────────────────────  ──────────────────  ────────────────
     DevHub1              devhub1@************.com         AAAAAAAAAAAAAAAAA1  Connected
     DevHub2              devhub2@************.com         AAAAAAAAAAAAAAAAA2  Connected
(D)  DevHub3              devhub3@************.com         AAAAAAAAAAAAAAAAA3  Connected

Solution

In order to change the default DevHub org from DevHub3 to DevHub1, run the following command in your Terminal:

% sfdx force:config:set defaultdevhubusername=devhub1@************.com --global

and you should receive the following result

=== Set Config
NAME                   VALUE
─────────────────────  ───────────────────────────────
defaultdevhubusername  devhub1@************.com

and after running the list command, that’s the result expected:

% sfdx force:org:list                                                                 
=== Orgs
     ALIAS                USERNAME                         ORG ID              CONNECTED STATUS
───  ─────────────────── ───────────────────────────────  ──────────────────  ────────────────
(D)  DevHub1              devhub1@************.com         AAAAAAAAAAAAAAAAA1  Connected
     DevHub2              devhub2@************.com         AAAAAAAAAAAAAAAAA2  Connected
     DevHub3              devhub3@************.com         AAAAAAAAAAAAAAAAA3  Connected

By Marcin Krzych

Author of "The CPQ Implementation Guide" book. In IT since 2007, In Salesforce ecosystem since 2011, In Salesforce CPQ projects since 2016.
8 SF certifications.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.