Learn How to Save Your Notebooks to Github and Keep Your Work Safe

Google Colab and GitHub: A quick overview

If you develop Python code for software projects on Google Colab, chances are that you utilize GitHub, the popular online platform for source code management. GitHub is frequently used for bug tracking, code branching, and code storage, allowing teams to work independently on different aspects of a project without interfering with each other’s work.

If you are interested in learning Python coding, there are various coding apps on the Google Play Store that teach Python and SQL, among other languages. For those who work with a budget-friendly Chromebook, using Google Colab and GitHub can help accomplish coding tasks and share code with fellow programmers.

Why connect Google Colab notebooks and GitHub repositories?

Google Colab is a web-based Jupyter notebook environment that allows Python code writing and execution. It allows teams to collaborate on code and create project documentation with tables, images, LaTeX, and HTML. Google Colab is widely used in artificial intelligence (AI) and machine learning (ML) projects, as well as non-technical education projects and data analysis. GitHub and Google Colab may seem similar since they provide code writing, storage, management, sharing, and editing features. However, you will need to clone GitHub code onto a local computer, set up an integrated development environment (IDE), or use cloud-based IDEs like Google Colab to run code on GitHub.

The advantage of using Google Colab alongside GitHub is that Colab utilizes Google’s computational infrastructure to execute code, making it an ideal tool for AI projects. Many people find using GitHub in conjunction with Google Colab useful. In fact, Google Research developed Google Colab with GitHub integration features in mind, making linking the two seamless.

How to set up Google Colab and GitHub integration

The integration between Google Colab and GitHub is straightforward because it is already built into the software. If you are new to Google Colab, you need to install it from the Google Workspace Marketplace before you start implementing the integration.

Install Google Colab

  1. Sign in to your Google account and click on the icon beside your profile picture at the top-right corner.
  2. Scroll down and select More from Google Workspace Marketplace.
  3. Type Colaboratory in the search bar and select the app from the search results.
  4. Click on the blue Install button.
  5. When you click Install, Colaboratory requires permission to start the installation. Click Continue.
  6. Once the installation is complete, click Done.

Create a Google Colab notebook

After installing Google Colab, you can start creating notebooks. Notebooks are stored in Google Drive, so you will create one there.

  1. Open Google Drive, navigate to an existing folder, or create a new one where you want to save your notebooks.
  2. Click on the New button at the top-left corner of the page.
  3. Click More to access other options and then click on Google Colaboratory to create a new notebook in Google Colab.
  4. Once the Google Colab app opens, name your new notebook. You will use this notebook to link Colab with GitHub.

Connect Google Colab with GitHub

Linking Google Colab with GitHub is easy, and once the integration is established, all your future notebooks will be saved to GitHub.

  1. From your Google Colab notebook, click on the File menu.
  2. Select Save a copy in GitHub from the dropdown menu.
  3. A popup window will appear, asking you to authorize popups from Google Colab. Click on the Authorize googlecolab button in green to continue.
  4. Select the repository and branch in GitHub where you want to save your Colab notebook.
  5. If you wish, you may add a commit message.
  6. Select Include a link to Colaboratory to make it simple to access your notebook in GitHub easily.
  7. Click OK to save.
  8. The notebook opens in GitHub in a separate web browser tab, and you’ll see the Open in Colab button at the top of your code.
  9. Alternatively, select Open notebook from the Google Colab File menu, and choose GitHub from the top menu. You can then browse your GitHub location to select the notebook you want to open.

Google and GitHub make integration easy

Integrating Google Colab and GitHub is a straightforward process. GitHub provides the version control necessary to work with large projects, including branching code to work on issues safely without affecting the project’s other aspects. Google Colab provides cloud-based IDE services and flexible computing power to test changes before merging code into the mainline source code.

These two platforms together offer an abundance of tools to create and collaborate on AI projects, innovate and get ideas for future technical projects. Enjoy tinkering with machine learning in Google Colab and GitHub!