Version Control

Code Ocean uses Git for version control. Each compute capsule is a Git repository, and you can perform Git operations via either the IDE or any (CLI) command-line interface in a Cloud Workstation.

Each file or folder has a small status icon that indicates its status in Git:

Icon

is tracked by Git?

is committed?

Yes

Yes

Yes

No

No

No

The 1-Click Commit

Every edit from the IDE is automatically saved and staged in Git by default. The Commit Changes button appears in the Timeline after each new edit.

1. In Describe what changed, explain your actions, or leave the default commit message.

2. Click Commit Changes to commit your changes to Git history stored in the capsule and push the commits to the capsule's Git repository.

The yellow icons of files and folders turn green after selecting Commit Changes.

.gitignore

The .gitignore file indicates files or folders that you want to exclude from version control. Git won't keep track of changes in these files. Code Ocean automatically adds/data/to follow best practices of excluding data files in version control.

Viewing Changes

View Committed Changes

Click committed to display the status update of committed changes. In the image below, you can see the files that were added.

Click Back to Timeline to return to the IDE.

View Uncommitted Changes

  1. Click on the run file in the left section.

  2. Copy and paste # view the power of git to line 10.

In your Timeline, you’ll see one uncommitted change, which is the piece of code you added. Click 1 uncommitted change to see the details.

Click the down-arrow and from the menu select View Changes. A Git compare view will open up in the middle workspace. Here you can view the changes you made.

Filtering Changes

Changes can be filtered in the Select filter dropdown list by:

  • All

  • Git

  • Runs

The Native Git Experience

In Code Ocean, each Compute capsule is a Git repository with full Git functionality. You can use advanced Git commands in a terminal environment launched via the Cloud Workstation app.

Clone a Compute Capsule

When you clone or duplicate a capsule, you copy both the committed history and the uncommitted changes.

  1. From the top menu, click Capsule and select Duplicate. You are redirected to the duplicated capsule.

  2. Verify that your uncommitted changes appear in the Timeline.

  3. Click Show Prior History to view the commit history from the parent capsule.

Switching Branches

Switching between the different Git branches is available in your capsule's Git repository via the drop-down menu shown below. The default branch is master unless defined otherwise in the remote Git repository. You can also create and delete Git branches from within a Cloud Workstation session.

Once you start editing the capsule, the drop-down button for switching branches is disabled until all of the changes are committed.

This feature is especially useful when the capsule is linked to an external Git repository (e.g. GitHub, GitLab, etc.).

You can also create and delete Git branches from within a Cloud Workstation session. This will be synced into your capsule as well and reflected in the Git branch list of the drop-down menu.