Using GitHub with Google Colab
Google Colab has convenient Git integration. This will enable you to edit notebooks in Colab and then commit and push changes back to the repository without ever leaving Colab in your browser.
Setting up GitHub access from Colab
In order to access Git repositories, you need to allow Colab to access the repositories. To set this up, make sure you are logged in to your Caltech G-Suite. Then, follow the steps below.
Go to the main Google Colab page. You will get a splash page that looks like this.
Click the checkbox for including private repos if you also want to include repositories you have set to be private.
An authorization window from GitHub will pop up. (Make sure you are not blocking pop-up windows.) You should authorize Colab to access your repositories.
Under where it says “Enter a GitHub URL or search by organization or user,” search for the desired repository name. Underneath the search bar, you will have a pulldown menu of available notebooks. Select the one you want to work on.
Pushing your notebook to the repository
After you have made changes to your notebook, you can commit and push them to the repository. To do so from within a Colab notebook, click File
→ Save a copy in GitHub
. You will be prompted to add a commit message, and after you click OK
, the notebook will be pushed to your repository.
Chrome plug-in for quick access
If you use Chrome as your browser, there is a convenient plug-in called Open in Colab that allows you to open a notebook from any GitHub page in Colab. So, after installing the plugin, if you are on the webpage of your team’s repository, you can click the icon next to the address bar in your Chrome browser and the notebook will open in Colab. You can then proceed to push the notebook back to the repository after making your changes as described above.