JupyterLab Git Extension

January 21, 2022 | 8 minute read
Wendy Yip
Data Scientist
Text Size 100%:

OCI Data Science is adding the Git extension inside the JupyterLab Notebook. This feature allows customers to easily use Git to version control their code in the notebook session.

What is Git?

Git is a version control system that allows you to track changes made to a set of files and allows you to revert to previous version of the files as needed.  It is important to version control your code so you can keep track of the changes you have made as you work through your data science project.  By using a version control system, teams can collaborate together by having a repository of files that team members can contribute to and add in their changes through merge requests.

What is Git Extension?

The Git extension is a user-friend add-on for JupyterLab that allows users to do basic git actions with a point-and-click interface.  It works with cloud-based hosting services such as GitHub and GitLab which let you manage repositories of files you want to keep track of.  You can access the Git extension by logging into the JupyterLab Notebook and clicking on the Git icon on the left-hand side of the Notebook. Also, you will see the “Git” tab.  If you do not see them, you might be using a notebook with an older image.  You can deactivate and reactivate your notebook session in order to access the Git extension.

Let's go through how you can create a new local git repository and commit files to the repository and clone a remote repository.

Git Setup

When you use Git for the first time in the Notebook session, you need to go through some configuration steps. Here are the steps to configure Git and authenticate a GitHub account:

  1. Go to File, Select "New Launcher". Start a new Terminal window.

In the terminal, you can enter your Git username and email associated with your Git account with the command below in the terminal.

  $ git config --global user.name "Jane Smith"

  $ git config --global user.email jane.smith@oracle.com

You can check your settings at any time with the command below:

  $ git config --list

You need to set up ssh key for authentication to the Git website.  If you do not already have a ssh key you can use, you need to generate a one. Go to the terminal and paste the command below, substituting the email with your GitHub user email

  $ ssh-keygen -t ed25519 -C "jane.smith@oracle.com" 

You will see a screen like this belowYou can press “Enter” to accept the default location of where to save the key.

In the next step, you will be prompted to enter a secure passphrase.  

Then, you will need to add your SSH key to the ssh-agent

Type the following command in the terminal

  $ eval "$(ssh-agent -s)"

Then you can add your SSH private key to your ssh-agent with the command below.  If you had created your key with a different name or used an existing key, replace id_ed25519 in the command below with your private key file.

  $ ssh-add -K ~/.ssh/id_ed25519

Next, display the contents of the id_ed25519.pub file

   $ cat ~/.ssh/id_ed25519.pub

Copy the content to your clipboard.  You will add it in your Github account.

Go to your GitHub account and click on your Avatar.  Go to Settings

Then Click “SSH and GPG keys” on the left panel and then click “New SSH key” on the top



You will be able to paste in your SSH key from your terminal in here.

For more information about the process of setting up your ssh keys for authentication to a GitHub account, you can visit https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account.  For information about authentication to a GitLab account, you can visit https://docs.gitlab.com/ee/ssh/index.html#add-an-ssh-key-to-your-gitlab-account

Creating a new local Git Repository

  1. Click on the Folder icon to create a new folder and rename it to your own choosing.

  1.  Put all the files you want to associate with this new repository in the folder

  2. Move into your folder by double-clicking on it. Then, click on the Git tab and select Initialize a Repository, as shown here:  

  1. Then, a popup will ask for confirmation; click on YES

Now, your local repository has been created and you can start committing files to the repository.

Committing files to the repository

Adding files to your repository is important as you make changes to your files. Let's walk you through how we can commit changes to the repository:

  1. If you have not already done so, create a git repository you want to push your files to.

  1.  Go to the Git tab in the console and click Add Remote Repository


A screen will pop up for you to add a remote repository

  1. Go to the top of your repository you want to commit files to and copy the remote repository URL and paste in the pop-up window

  1.  Go back to the console and click the “+” sign next to the file you want to commit.  This will stage the file to be committed.

  1. The file will be moved to “Staged”. You can add a commit message and click “Commit”

  1.  Go back to the Git tab and click Push to Remote


  1.  You can check to make sure your file is in your git repo


Cloning a Repository

If you want to clone a repository from your GitHub account to your notebook, you can follow these steps

  1.  Go to your notebook, click on the Git tab and click Clone a Repository


  1.  You will get a pop up to enter the URL of the repository you want to clone
  2. Go to the Git repo you want to clone and copy the repository URL and paste it in the pop up

You can verify you have cloned your repository.


You can read more about JupyterLab Git Extension in the documentation here https://github.com/jupyterlab/jupyterlab-git



Wendy Yip

Data Scientist

Previous Post

DLS V2 Launch Announcement

Praveen Patil | 4 min read

Next Post

Announcing OCI Vision service

Kate D'Orazio | 5 min read