Version Control
Last updated
Was this helpful?
Last updated
Was this helpful?
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
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 .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.
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.
Click on the run
file in the left section.
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.
Changes can be filtered in the Select filter dropdown list by:
All
Git
Runs
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.
When you clone or duplicate a capsule, you copy both the committed history and the uncommitted changes.
From the top menu, click Capsule and select Duplicate. You are redirected to the duplicated capsule.
Verify that your uncommitted changes appear in the Timeline.
Click Show Prior History to view the commit history from the parent capsule.
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.
The files and folder in .gitignore
have a gray icon to indicate that these files aren’t tracked by Git.
The Timeline shows the history of the reproducible run (marked with a blue circle ) and the committed changes to this capsule (marked with a green circle ).