Configuration#

The minimal amount of configuration for git to work without pestering you is to tell it who you are. You should run a version of these commands in your shell:

git config --global user.name "Fernando Perez"
git config --global user.email "Fernando.Perez@berkeley.edu"

And while we’re at it, we also turn on the use of color, which is very useful

git config --global color.ui "auto"

Convenient credentials management#

Next, we configure git so that we manage our credentials without having to manually type our passwords for each and every operation.

For general users, Github offers in its help pages instructions on how to configure the credentials helper for Mac OSX, Windows and Linux.

But in this document we will focus on configuring the github app for JupyterHub developed by Berkeley’s Yuvi Panda. Our JupyterHub already has this app pre-installed, which makes it very convenient to push and pull securely from selected repositories.

You will need to run this command from a cell of a Jupyter notebook

import gh_scoped_creds
%ghscopedcreds

For convinience, we have added a notebook with this cell and some further explanation in the shared folder in your JupyterHub session. You can copy this notebook in your home directory and use it every time you need to authenticate with GitHub. Alternatively, you can run the following command in your terminal

github-app-user-auth

This will display a link and a code to input into the website you access with the link. Open the link and enter the code there. Grant access to the device in the web page, and you’re done!

The first time you do this you need to go to the configuration page and manually configure which repositories you will be using (this will require a bit more manual maintenance through the semester).

Authentication is valid for 8 hours, and once it expires, this process will need to be repeated, except for the first step. In the future, we might have a web application or other process to make this less painful. However, keeping the length of this session limited drastically helps with security too.

Later, you can see what repositories you’ve given it access to by visiting your GitHub installations page.