Documentation
Repositories
Getting Started
Branching

Repository & workflow setup

Branching flow

CodeSandbox has an opinionated flow when it comes to working with repositories, and you can see hints of this in the editor.

As soon as you enter the editor, you will see the current branch name in the header. Every branch has its own VM and is available through a unique URL. For example, if two people visit the URL for the main branch, they will be able to see each other's cursor, terminals and DevTools.

💡
URLs for branches are predictable. So, if you want to open a specific branch, you can update the URL with the new branch name, and we'll import & create an environment for that branch automatically.

On CodeSandbox, the main branch is protected by default. This means that it's read-only and will sync automatically with the branch on GitHub when new commits come in.

To write some code, you have three options:

  1. (Recommended) Just start typing some code - we will create a new branch for you using seamless branching!
  2. Click the “Branch” button in the header.
  3. Toggle protection off for the main branch.

When we create the new branch, we create a clone of the main VM and switch it to the new branch. This new VM is an exact copy of the original VM, down to the memory contents. Because of this, processes like dev servers are already started in the cloned VM.

💡
Tip: you can start a Postgres database on the main branch, seed some data in it, and then every new branch created from main will have that data available.