All Collections
Version Control
Moving repositories in and out of Code Ocean
Adding a Code Ocean capsule as a remote to an existing git repository
Adding a Code Ocean capsule as a remote to an existing git repository

For integrating Code Ocean into your local development process

Updated over a week ago


This article assumes that you have a git repo on your computer and that you are reasonably comfortable with Git commands. If you are just getting started with git, you can follow along by forking and then cloning a public GitHub repo, such as (some basic R scripts I wrote a few years ago).


First, after creating a Code Ocean account, navigate to and create a new capsule (note: don't add any files, or configure the environment or metadata). There will be a new commit for the metadata.yml generated by the system. Please commit the changes so you can push it to the remote repo in the following step.

Second, click the capsule menu and select 'Clone via Git':

You will then see a message to appear with your capsule's git information:

Third, rather than cloning the capsule directly, you will copy and paste that link (for this example, it's, but it will be something different for you). 

Fourth, navigate to your local git repo on your computer, run git init if you have not already, and add the copied link as a remote (here the remote is called co ):
git remote add co 

You can check this worked by running git remote -v :

(base) my-computer:my-directory my-username$ git remote -v

co (fetch)
co (push)

Next, you will push your local files to Code Ocean by a command like git push co master (My local repo is on the master branch but yours might not be). 

If this is your first time running git push  from your computer, you will be prompted for your username and password. Use your username and password for Code Ocean.

Your capsule will then show that changes are being pushed:

You can now push, pull, etc. between your local repo and Code Ocean, and the capsule will have your full git history displayed on its timeline.

Note: once you've set up the capsule as a remote, you no longer need to have the capsule open, nor to be logged in, to push your code.

Did this answer your question?