While you can create a capsule by importing an existing git repository from GitHub, GitLab, or other git hosts, a natural next step is to synchronize changes – either pushing changes you've made on Code Ocean to GitHub (for the sake of example), or pulling changes from GitHub to Code Ocean.
Although capsules don't do this automatically, the underlying git infrastructure makes it possible to do both things by running a few git commands.
First, you'll want to start a Cloud Workstation terminal session if you aren't already at the terminal (JupyterLab and R Studio both offer built-in terminals).
Second, make sure you have your repository URL (for example, https://github.com/OceanCodes/HelloCodeOcean.git) and run the following commands:
git remote add <remote-name> <repo-url>
, e.g.git remote add github https://github.com/OceanCodes/HelloCodeOcean.git
. This is a configuration step you'll need to run every time you start Cloud Workstation since it doesn't persist across sessions (the remote name is arbitrary – anything will work.)If you're pulling new changes into Code Ocean,
git pull <remote-name> master
, e.g.git pull github master
. If you're pushing changes from Code Ocean, changepull
topush
. (Note that this command may result in conflicts if you've made changes to both Code Ocean and your repository.)