Set Up Git in JupyterHub
We recommend syncing content to and from JupyterHub using Git and GitHub. However, before you can start, we will need to tell Git and GitHub who we are.
1. Configure Git
First, add your name and email to git config (lines 1 and 2). Also set git to always clone using SSH (line 3). Line 4 sets the default branch name to main
instead of the traditionally used master
.
2. Generate and SSH Key and add it to GitHub
Start a terminal session inside your hub using the terminal launcher (#18 in the Interface Overview)
Generate an ssh key:
This creates a new ssh key, using the provided email as a label.
3. When you're prompted to "Enter a file in which to save the key," press Enter. This accepts the default file location:
4. You will be asked for a passphrase. If you will be using nbgitpuller magic links in combination with git, please leave ot empty, the passphrase prompt may break nbgitpuller. If you leave it empty, you won't be asked for the passphrase when connecting to GitHub. For more information, see "Working with SSH key passphrases".
5. Add your SSH Key. The command below will show the public SSH key on the terminal. Copy the entire key, starting with ssh-rsa
and ending with your email.
6. Go to https://github.com. In the upper-right corner of any page, click your profile photo, then click Settings.
7. In the user settings sidebar, click SSH and GPG keys.
8. Click New SSH key or Add SSH key.
9. In the "Title" field, add a descriptive label for the new key. For example, if you're using a personal Mac, you might call this key "Personal MacBook Air".
10. Paste your key into the "Key" field.
12. If prompted, confirm your GitHub password.
3. Test your ssh connection:
In the terminal of your hub type
After accepting the host key you should received:
3. For more information check GitHub's documentation:
https://help.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh
Last updated