Notebooks

Working with Git

Clone, pull, and push a repository from a notebook session.

Git works normally in your home folder in Notebooks: it is real disk, and git is already set up. Keep repositories out of the shared folder, where git does not work. Your home is not backed up, so an unpushed commit is the only copy: push often.

Clone and push a repository

Create an access token

Git over HTTPS needs a token, not your password.

  • GitHub: create a fine-grained personal access token with Contents: Read and write on the repositories you need, and copy it once. See GitHub’s guide.
  • Bitbucket: create a repository access token. Bitbucket shows a ready-made clone link that includes the token; you can use that link directly.

Treat the token as a password: never commit it or paste it into a notebook.

Clone the repository

Use the Git panel in the JupyterLab sidebar (Clone a Repository) and enter the HTTPS URL, or a terminal:

Clone over HTTPS
git clone https://github.com/<org>/<repo>.git

Use the HTTPS URL (ending in .git), not the SSH one (git@...). For the panel, see the jupyterlab-git documentation.

Authenticate once

When git asks for credentials, enter your username at the Git provider and paste the token as the password. Git caches it in ~/.git-credentials in your private home, so later sessions do not ask again.

Commit and push

Git takes your name from your Databaas login, or your username if your login has no name. It takes your email from your login too, but only when your login has one. Check with git config user.email; if it prints nothing, set it once:

Set your email, if it is missing
git config --global user.email "<you@example.com>"

New repositories start on main, and git pull merges rather than rebases.

Commit and push
git add -A
git commit -m "Explore the transactions table"
git push

Reset a token that expired or was rotated

Authentication failures are usually an expired token, or a token without access to that repository. Remove the cached credential and authenticate again on your next git command:

Clear the cached token
rm ~/.git-credentials

This removes every cached Git credential, not only the one that failed.