Integrating Colaboratory and Github

rajath cs
3 min readJan 31, 2021

Introduction

Working with scripting projects and keeping track of the changes might be a hefty task with various git commands to go through and also have a local Jupyter Notebook running. This is especially true working with private repositories for data science projects which need to be executed in a notebook environment including many datasets. For this scenario, having an integrated workflow of version control with a cloud based notebook becomes handy. This is where Google Colaboratory comes in handy. In this blog, I walk you through how to make git commits easily using GColab UI.

Steps for Integration

Although there is a programmatic way of integrating Colab with Github doing it via GUI is a seamless process. Also, the programmatic way needs one to integrate Google Drive too [1]. The below code lines show you how to go about the same, but in this blog, we will easen the process by eliminating the need for it.

Note: These are precisely the same steps for integrating a public repository too.

  1. Create a new private GitHub repository with a ReadMe file.
Post Creation of Private GitHub Repository
  1. Open GColab.
  2. In the pop-up dialog box, select ‘NEW NOTEBOOK’. The text highlighted in blue.

3. Once you click on ‘NEW NOTEBOOK’, colab will open a new notebook like below with the name ‘Untitled0.ipynb’. I renamed it to ‘medium_colab_git_test.ipynb

4. Click on File → Save a Copy in Github → It will redirect to a new page and ask you to authorize (O Auth). Click on ‘Authorize’. Sometimes it doesn't ask you to ‘Authorize’.

5. Once you ‘Authorize’, you are good to make commits to the same private repo. To do so, Go to: File → Save a Copy in Github. Write your commit message and then click on ‘Ok’

6. You should now be able to see the same reflecting on your github.

8. Note: Make sure the ‘Include Private Repos’ is checked. You can find this dialog box when you click on File → Open Notebook

Advantages

  • It makes it easier for developers who are accustomed to working with Git. Especially git diff for viewing the file changes.
  • It helps you build your Github commit dashboard.

References

  1. https://medium.com/analytics-vidhya/how-to-use-private-github-repositories-with-google-colab-f7fb0958f47c

Conclusion

There are many blogs describing various ways of having a workflow between Github’s version control mechanism and Colab’s notebook environment. Through this article, we realized that the process is much more straightforward.

Happy Datascincing!!!

--

--