Switching Lanes

Run the following to list all lanes available in your workspace:

$bit
Copiedcopy

The output notifies of the current checkout lane and lists additional lanes that are available in the workspace:

current lane - my-org.my-scope/my-lane

Available lanes:
> my-org.my-scope/my-lane (0 components)
> main (0 components)

Run the following command to switch to a lane (available locally) using its lane name:

$bit
Copiedcopy

By default, components that do not already exist in your workspace, will not be checked out. To check out all components in a lane, run the command with the --get-all flag:

$bit
Copiedcopy

If you have modified components in your workspace (that are not snapped), you can switch to a different lane and merge these component changes with the checked out components from the lane you are switching to:

$bit
Copiedcopy

Provide the --merge flag with a merging strategy: theirs, ours or manual

Switch to a lane not available locally

To switch to a lane that is not available in your workspace, provide the command with the full lane ID:

$bit
Copiedcopy

Alternatively, run the following to import a lane and switch to it:

$bit
Copiedcopy

When importing a lane, all its component will be checked out, including those that are not currently maintained in the workspace (similar to the bit switch LANE_ID --get-all)

What changes in the workspace when switching lanes?

When you switch to a lane, your workspace .bitmap file references that lane.

For example, the following switches to the my-lane lane:

$bit
Copiedcopy

The .bitmap file is updated to reference that lane:

"_bit_lane": {
        "id": {
            "name": "my-lane",
            "scope": "my-org.my-scope"
        },
        "exported": false
    }
CopiedCopy

Components listed in the .bitmap file are marked as isAvailableOnCurrentLane, if they are part of the checked-out lane.

{
    "my-component": {
        "scope": "",
        "version": "5bde67a71c29be5a6d256ab37130bb6a7499aef5",
        "mainFile": "index.ts",
        "rootDir": "my-scope/my-component",
        "onLanesOnly": true,
        "isAvailableOnCurrentLane": true
    },
}
CopiedCopy

Components marked as onLanesOnly and isAvailableOnCurrentLane will be handled by Bit (and show up in commands like bit status and bit list), only when you are on that lane.

For example, the following workspace is now set to the my-lane lane:

$bit
Copiedcopy

The output confirms that the workspace is now set to the my-lane lane. Components in that lane are listed.

showing information for my-org.my-scope/my-lane
author: Jane <jane@my-org.com> created: 5/17/2023, 12:28:03 PM components (1) my-component@5bde67a71c29be5a6d256ab37130bb6a7499aef5

When listing the components in that workspace, the same components listed above are shown:

$bit
Copiedcopy

The output is as follows:

┌──────────────────────────────────────┬──────────────────────────────────────────┬──────────────────────────────────────────┐ │ component IDlatest in scopeused in workspace │ ├──────────────────────────────────────┼──────────────────────────────────────────┼──────────────────────────────────────────┤ │ my-org.my-scope/my-component-on-main │ 5bde67a71c29be5a6d256ab37130bb6a7499aef55bde67a71c29be5a6d256ab37130bb6a7499aef5 │ └──────────────────────────────────────┴──────────────────────────────────────────┴──────────────────────────────────────────┘

Note that new components will not show up in the output of bit lane show, but will show up in the output of bit list, as they are not part of any lane yet.

If you switch to "main lane" or another lane, the .bitmap file is updated accordingly.

For example, the following switches to the "main lane":

$bit
Copiedcopy

Components available only on the "my-lane" lane, are now set as isAvailableOnCurrentLane: false:

{
    "my-component-on-main": {
        "scope": "",
        "version": "5bde67a71c29be5a6d256ab37130bb6a7499aef5",
        "mainFile": "index.ts",
        "rootDir": "my-scope/my-component-on-main",
        "onLanesOnly": true,
        "isAvailableOnCurrentLane": false
    }
}
CopiedCopy

Bit will ignore these components, unless you switch back to the "my-lane" lane.

For example, running the following, while still on the "main lane":

$bit
Copiedcopy

Will show no components are available in the workspace:

found 0 components

That means that the components listed in the .bitmap file are marked as isAvailableOnCurrentLane: false and are no longer handled by Bit.

When you run bit list you will only see components that are marked as isAvailableOnCurrentLane: true

Do files in the workspace directory reflect changes in the checked out lane?

Having the components' files in your workspace directory does not mean these components are part of that lane! This is contrary to Git, where files in your working directory are part of the branch you are on. To understand this better, let's look at the following scenario:

  1. The hello-world component is in the workspace directory. A newer version of that component is in the my-lane lane.
  2. The goodbye-world component is not in the workspace directory, but is in the my-lane lane.
  3. The hello-moon component is in the workspace directory, and is not in the my-lane lane.

The following shows the workspace directory before switching to the my-lane lane:

. ├── my-scope │ └── hello-world │ ├── hello-world.ts │ └── hello-moon │ ├── hello-moon.ts

Let's run the following to check out the my-lane lane:

$bit
Copiedcopy

Now that the workspace has switched to my-lane lane, the workspace directory is updated as follows:

. ├── my-scope │ └── hello-world │ ├── hola-mundo.ts <-- a new file, from the latest snap of the component, in the lane │ ├── hello-world.ts │ └── goodbye-world <-- a new component, from the lane │ ├── hello-world.ts │ └── hello-moon <-- a component that is not part of the lane, but its source files remain in the workspace directory, even after switching to the lane │ ├── hello-world.ts