Clone via Git...
Securely clone your pipeline’s Git repository so you can work locally or in another Git-enabled environment.
Git clone your Capsule to your computer
Click the Capsule menu and select Clone via Git.
This will provide you with the appropriate Git repository URL.
Copy and paste the URL and via a terminal or Git client, run
git clone [url]
.This will prompt you for your username and password. The username is your email used to log in to Code Ocean, and the password is the text generated by clicking "Generate New Access Token" button in the above screenshot
From that point, you can push, pull, etc. to the corresponding Code Ocean Capsule.
Adding a Code Ocean Capsule as a remote to an existing git repository
This section 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.
1. Click the Capsule menu and select Clone via Git:
A message to appear with your Capsule's git information:
Click the clipboard icon in Step 2 to copy the Github clone URL
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 (in the below example, the remote is calledco
):git remote add co https://git.codeocean.com/capsule-<id>.git
You can check this worked by running
git remove -v
Push your local files to Code Ocean by a command like
git push co master
(in this example, the 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.
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.