Edit on GitHub

exp branch

Commit the results from an experiment in a new Git branch.


usage: dvc exp branch [-h] [-q | -v] experiment branch

positional arguments:
  experiment     Experiment to commit/merge
  branch         Git branch name to use


Makes a Git branch off the last commit (HEAD) based on the given experiment, using the branch name provided. This makes the given experiment persistent in the repo.

In most cases this is similar to using dvc exp apply (applies the experiment results to the workspace) followed by Git branching and committing, except that dvc exp branch does not switch into the created branch. Equivalent to this:

[master] $ git checkout -b <branch>
[branch] $ dvc exp apply <experiment>
[branch] $ git add . && git commit
[branch] $ git checkout master

For checkpoints, the experiment (custom Git branch with multiple commits) is merged into the new branch.

To switch into the new branch, use git checkout branch and dvc checkout.


  • -h, --help - shows the help message and exit.
  • -q, --quiet - do not write anything to standard output. Exit with 0 if no problems arise, otherwise 1.
  • -v, --verbose - displays detailed tracing information from executing the dvc pull command.

Example: Make a persistent branch from an experiment

This example is based on our Get Started, where you can find the actual source code.

Let's say we have run 3 experiments in our project:

$ dvc exp show --include-params=featurize
โ”ƒ Experiment            โ”ƒ Created      โ”ƒ     auc โ”ƒ featurize.max_features โ”ƒ featurize.ngrams โ”ƒ
โ”‚ workspace             โ”‚ -            โ”‚ 0.61314 โ”‚ 1500                   โ”‚ 2                โ”‚
โ”‚ 10-bigrams-experiment โ”‚ Jun 20, 2020 โ”‚ 0.61314 โ”‚ 1500                   โ”‚ 2                โ”‚
โ”‚ โ”œโ”€โ”€ exp-e6c97         โ”‚ Oct 21, 2020 โ”‚ 0.61314 โ”‚ 1500                   โ”‚ 2                โ”‚
โ”‚ โ”œโ”€โ”€ exp-1dad0         โ”‚ Oct 09, 2020 โ”‚ 0.57756 โ”‚ 2000                   โ”‚ 2                โ”‚
โ”‚ โ””โ”€โ”€ exp-1df77         โ”‚ Oct 09, 2020 โ”‚ 0.51676 โ”‚ 500                    โ”‚ 2                โ”‚

We may want to branch-off exp-1dad0 for a separate experimentation process (based on 2000 max_features).

$ dvc exp branch exp-1dad0 maxf-2000
Git branch 'maxf-2000' has been created from experiment 'exp-1dad0'.
To switch to the new branch run:
        git checkout my-branch

We can inspect the result with Git:

$ git branch
* master

maxf-2000 can now be checked out, merged, rebased, pushed, etc. like any other Git branch.


๐Ÿ› Found an issue? Let us know! Or fix it:

Edit on GitHub

โ“ Have a question? Join our chat, we will help you:

Discord Chat