Background:

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 https://github.com/setgree/ACT_score_analysis (some basic R scripts I wrote a few years ago).

Walkthrough:

First, after creating a Code Ocean account, navigate to codeocean.com/dashboard and create a new capsule (note: don't add any files, or configure the environment or  metadata).

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 https://git.codeocean.com/capsule-3518220.git, 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 https://git.codeocean.com/capsule-3518220.git 

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

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

co https://git.codeocean.com/capsule-3518220.git (fetch)
co https://git.codeocean.com/capsule-3518220.git (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?