An example use case may be a development team where each developer has their own personal sandbox, but may be working on multiple projects at the same time. The developer could create unique Git branches for each piece of work, and can use branch switching to switch between them and have their personal sandbox updated with the metadata in the branch that they switch to.
Branch switching is only available with an Enterprise edition subscription.
The default process is: Flow In changes from the environment's Salesforce org, change the branch on the environment's record in the State Store, and then Flow Out from the new branch to the environment's Salesforce org.
If the branch you are switching to does not yet exist, OrgFlow will create it from the head of the environment's current Git branch. Otherwise, the branch will be left as is on the remote repository.
When switching branches, OrgFlow will check for the most recent Snapshot that is associated to the branch you are switching to. If no snapshot is found, OrgFlow will do a Flow Out from the head of the branch you are switching to.
If a snapshot is found, OrgFlow will apply the snapshot to the environment (similar to a Rollback). This allows for the environment's Environment State to be restored to the way it was when the environment's branch was switched away from this branch.
Switching an environment's branch can impact the behaviour of other commands:
env:rollback will warn and prompt for confirmation before rolling back to a snapshot that is associated with a Git branch that differs from the environment's current Git branch. The environment's Git branch will be switched back to the Git branch associated with the target snapshot. After the rollback has been completed, OrgFlow will delete only the snapshots that are associated to the same Git branch as the target snapshot (and are more recent than the target snapshot).
env:snapshot:list will only list snapshots associated to the environment's current Git branch. Use the
--showAllBranches switch to override this.
env:snapshot:delete will only delete snapshots that are associated to the environment's current Git branch.
Managing environment branches
There are commands that allow you to manage environment branches. They all begin with the prefix