CodeHerderSearch⌘KCtrl KGet started →

Choosing a task's base branch

Set the branch a task starts from and where its merge request lands. See what CodeHerder picks when you set none.

Every task builds its change on a starting branch. By default, that is the default branch of each repo the task works in. A task can work in more than one repo. See Tasks that span several repositories.

A task’s base branch replaces that default. You give one name, and it applies to every repo in the task. The task’s sandbox branches from it, and the task’s merge requests target it.

Use a base branch when a task belongs on a release branch or a long-lived feature branch.

Set a base branch when you create a task

Pass --base-branch to ch task create:

ch task create --title "Backport the auth fix" --type story --base-branch release/2.1

In the web app, the New task form has a Base branch field in the Placement group. The placeholder reads e.g. release/2.1. Leave the field blank to use each repo’s default branch. The New schedule form has the same field.

On the CLI, --base-branch "" is an error when you create a task. Pass a branch name, or leave the flag out.

Change it later

Use ch task edit to set a base branch on an existing task:

ch task edit <taskId> --base-branch release/2.1

Pass an empty string to clear it. The task then uses each repo’s default branch again:

ch task edit <taskId> --base-branch ""

In the web app, the task page has an editable Base branch row. Click it to set or clear the value. A task with no base branch shows Repo default in that row.

ch task show prints the base branch when the task has one. ch task edit prints the value it set or cleared.

Valid branch names

CodeHerder checks the name when you set it. It refuses a name that:

  • contains a space, a tab, a line break, or another control character,
  • contains any of : * ? [ \ ^ ~,
  • contains .. or @{,
  • starts with -,
  • starts or ends with /, or contains //,
  • ends with .,
  • has a path part that starts with . or ends with .lock, or
  • is only @.

The error says that the base branch is not a safe git ref. Fix the name and try again.

You cannot change it after work starts

You can change the base branch only while the task has no live sandbox. After a sandbox exists, its branch is already cut. CodeHerder refuses the change with this message:

baseBranch cannot change while the task has a live sandbox; the worktree is already checked out from the current base

Set the base branch before the task starts. If a task started on the wrong branch, create a new task with the right --base-branch.

Where a sandbox starts

CodeHerder picks a starting branch for each repo on its own. It uses the first of these that applies:

  1. The upstream’s branch, for a stacked dependent. This applies only in a repo where the upstream task has an open merge request. See Task dependencies.
  2. A base ref you give a single sandbox. You set it with ch sandbox create --base-ref <ref>.
  3. The task’s base branch.
  4. The repo’s default branch.
  5. The branch that the repo’s remote marks as its default. CodeHerder uses this when the repo has no default branch set.

A stacked dependent starts from its upstream’s branch even when you pass --base-ref. This holds only while the upstream’s merge request is open. After the upstream merges, the task uses its own base again.

CodeHerder checks this each time it provisions a sandbox. If you change a repo’s default branch, or clear a task’s base branch, the change applies to the next new sandbox.

A base branch that does not exist yet

Suppose you name a base branch that a repo does not have. CodeHerder creates it in that repo from the repo’s default branch and pushes it. This happens before the sandbox starts. It happens only in a repo that lacks the branch. A repo that already has the branch keeps it.

CodeHerder creates a branch only when the name is on the task. It does not create one for a --base-ref that you give a sandbox. If that branch is missing, the sandbox fails to provision and CodeHerder creates nothing. Check the name and try again.

CodeHerder also does not create the branch when:

  • a tag on the repo’s remote has that name,
  • the name looks like a commit ID,
  • CodeHerder cannot find the repo’s default branch, or
  • the name is the repo’s default branch.

In each case, provisioning fails with an error. Change the task’s base branch and try again.

If another person or device creates the same branch at the same moment, CodeHerder uses their branch and continues.

Schedules and copies

A schedule can carry a base branch. Set it with --base-branch on the schedule commands. Each task the schedule creates starts with that base branch. See Scheduled tasks.

ch task copy keeps the base branch of the source task. ch task schedule keeps it too, when it turns a task into a schedule.

Where merge requests land

The merge request that the build stage opens in each repo targets the task’s base branch. If a repo has no task base branch, the merge request targets the repo’s default branch. A stacked dependent’s merge request targets its upstream’s branch until the upstream merges. See How work flows for the full pipeline.

Last updated

Try it on one repository for two weeks.

File a task. An agent builds it. You see the cost of each task.

Try "pricing", "connect a device", or "who reviews the code"

↑↓ move · ↵ open · esc close