Advanced Git

This documentation is for Dash Enterprise.
Dash Enterprise is the fastest way to write & deploy Dash apps and
Jupyter notebooks.
10% of the Fortune 500 uses Dash Enterprise to productionize AI and
data science apps. Find out if your company is using Dash Enterprise.

Plotly uses Git to manage Dash app deployments.
This section serves as a reference for what Git commands are utilized,
when to use them, and why.

Initializing a Repository

If you have created a new folder for your Dash app, or have an existing
folder on your workstation, you need to initialize a local Git
repository before you can deploy your Dash app to Dash Enterprise.
You need to initialize the local Git repository from your app’s
root folder, thus:

$ cd myDashApp
$ git init
Initialized empty Git repository in .git/

Cloning a Repository

If you have an existing repository hosted on GitHub, or would like to
use one of the demo Dash apps from Plotly’s Gallery, then
you’ll need to clone the repository. You can achieve this by using the
git clone command:

$ git clone <repository-name>

Note: The above command will generate a local Git repository on your
workstation, which by default includes the remote GitHub repository
origin. If you’re concerned that you may accidentally push to this
repository, you can remove it. See the next section Managing Remote Repositories
for how to view and remove remote repositories.

Managing Remote Repositories

Once you have initialized your local Git repository or cloned an existing
repository from GitHub, you need to create a remote repository on
Dash Enterprise, which you will deploy your changes to.
Note that this remote repository will be your live (production) Dash app.


To create a remote repository:

$ git remote add <remote-name> <remote-URL>


To view all remotes:

$ git remote -v


To rename a remote repository:

$ git remote rename <existing-name> <new-name>


To remove a remote repository:

$ git remote rm <remote-name>

Deploying Changes

By default, Dash apps run on localhost, so you can only access them on
your local machine. To share a Dash app, you need to deploy your Dash app
to the Dash Enterprise platform. This can be achieved via a series of


git status and git diff are optional and are only required if you
wish to inspect before adding changes.


The demonstration below is a common way to deploy your changes:

$ git add .
$ git commit -m "a description of the changes"
$ git push <repository-name> main

Using Branches

If you want to try out a new feature or test something different with your
Dash app but don’t want to alter your main code, you can create a
branch to encapsulate these changes.


To view all branches:

$ git branch


To create a new branch:

$ git branch <branchname>


Once you’ve created a new branch, you need to check it out (i.e. navigate
to it).

$ git checkout <branchname>


If you have created a new branch and are happy with the changes, you can
add and commit these changes using the common git add . and
git commit -m "description" commands. To deploy these to Dash Enterprise,
you will need to deploy the branch into main:

$ git add .
$ git commit -m "a description of changes"
$ git push <remote-name> <branchname>:main


To rename a branch:

$ git branch -m <existing-name> <new-name>


If you no longer need the branch, you can remove it:

Caution: This command will delete the branch and all unmerged changes.

$ git branch -D <branch-name>


Additional Resources

For more information regarding version control and Git commands, see the official Git