Skip to main content

Working with branches

In Modelbit, different Git branches allow you to work separately from your teammates. Even more importantly, they let you use your Git-based code review, approval, and merge workflows as part of pushing your work to the main branch.

You can create a new branch using git, mb.create_branch or by clicking New Git Branch... in the Modelbit apps's branch picker.

Branches in Git

If you're working locally in a repository created by modelbit clone, then branches work exactly as you'd expect. Use git checkout to switch branches, and git branch to create branches.

tip

The modelbit package inherits the branch and authentication from the Git repo. Calling the Python API from a script within your Git repo will run in the context of whatever branch is currently checked out.

If you push a newly created branch, Modelbit will create a fork of your workspace with the changes from the branch.

Branches in Python

If you're in a Python environment, you can create branches with mb.create_branch and switch to them with mb.switch_branch:

mb.switch_branch("my_branch")

At this point, all datasets, models and deployments will come from the my_branch branch. New deployments will deploy to the my_branch branch.

Setting your branch during login

You can set your branch during notebook login using the branch= parameter:

import modelbit

mb = modelbit.login(branch="my-branch")