Skip to main content

Guide to Integrating Google Colab with GitHub

If this site helped you, please support us with a star! 🌟
Star on GitHub

Updated January 19, 2026: Content rewritten to reflect the latest development environment.

In this guide, we will explain practical steps to migrate your Python code from Google Colab to a professional development workflow using GitHub and local editors like VSCode or Cursor.

If you have been developing solely on Colab, these steps will help you establish version control with GitHub and a comfortable local editing environment, enabling a more efficient and scalable development process.

  • Repository Preparation: Setting up the environment on GitHub.
  • Initial Integration: Safely migrating code from Colab to GitHub.
  • Local Setup: Configuring modern editors (VSCode, Cursor, etc.).
  • Development Workflow: Establishing a daily development cycle.

Current Status and Goals​

Starting Point & Objectives
  • Current Status
    • Code exists only on Google Colab (.ipynb files)
    • GitHub account is ready, but no repository has been created yet
    • No code exists in the local environment
    • Version control with Git has not been implemented
  • Goals
    • Manage code history and versions via GitHub
    • Enjoy a comfortable editing experience in VSCode, Cursor, or other editors
    • Maintain seamless execution and testing on Google Colab

1. Preparing the GitHub Repository​

First, create a "container" (repository) on GitHub to receive the code from Colab.

Creating a GitHub Repository

  1. Log in to GitHub and click the "+" icon in the top right, then select New repository.
  2. Enter a Repository name (e.g., colab-data-analysis).
  3. Choose Public or Private. Private is recommended for personal projects.
  4. Under Initialize this repository with:, check Add a README file.
    • Note: Creating a README automatically generates the main branch, making the Colab integration smoother.
  5. Click the Create repository button.

2. Saving from Colab to GitHub for the First Time​

Save your current Colab notebook into the repository you just created.

  1. Open the target notebook in Google Colab.
  2. From the menu, select File > Save a copy in GitHub.

Select Save a copy in GitHub from menu

GitHub Authentication

If it's your first time or your session has expired, a popup will appear requesting access for Google Colab to your GitHub account. Click "Authorize googlecolab" to allow the integration.

GitHub Authentication Process

  1. Configure the save settings:
    • Repository: Select the your-username/your-repository-name you created.
    • Branch: Select main.
    • Commit message: Enter a descriptive message like Initial commit of notebook from Colab.

Save Settings Dialog

  1. Click OK to execute the save.

3. Setting Up the Local Development Environment​

Now, download (clone) the code from GitHub to your local machine and set up your editor.

Cloning the Repository​

  1. On your GitHub repository page, click the green Codeβ–Ό button.

GitHub Code Button

  1. Select the HTTPS tab and copy the URL.
  2. Open your terminal, navigate to the directory where you want to save the project, and run the clone command.
# Navigate to your documents folder (or any preferred location)
cd ~/Documents

# Clone the repository
git clone [COPIED_REPO_URL]

# Enter the cloned directory
cd [REPOSITORY_NAME]

Editor Configuration (VSCode / Cursor)​

While we use VSCode as an example here, the flow is identical for Cursor (the AI-powered editor) or other modern IDEs.

  1. Open the cloned folder in your editor (Tip: type code . or cursor . in your terminal).
  2. Install essential extensions for Jupyter Notebook (.ipynb) support:
    • Python: Language support
    • Jupyter: Required for rendering and running notebooks
  3. Pro Tip: Managing .ipynb Files in Git
    • To see strict text-based diffs for version control, right-click the .ipynb file in the explorer > Open With... > Text Editor.

VSCode Text Editor Selection

VSCode Right-click Menu

This displays the file in its raw JSON format, making it easier to track changes (diffs). When you want to edit or run it as a notebook, simply double-click it to open it in the standard Jupyter interface.

4. Daily Development Workflow​

From Editing to GitHub Sync​

  1. Edit Code Locally

    • Use your favorite editor (VSCode/Cursor, etc.) to implement ideas and take advantage of AI completions.
  2. Push Changes to GitHub

    • Once editing is complete, use the terminal to push your changes.
    git add .

    # Example messages: feat(new feature), fix(bug fix), docs(documentation)
    git commit -m "feat: add data preprocessing logic"

    git push origin main
  3. Verify/Run on Colab

    • Open Colab, go to File > Open notebook, and switch to the GitHub tab.

Colab Open Notebook GitHub Tab

  • Select your repository (or search by URL) and open the updated notebook.

Colab Repository Search


Important Best Practices​

To maintain a smooth integration and avoid merge conflicts, follow these rules:

1. Always "Sync" Before You Start (Most Important)​

It is easy to forget where you made the last edit. Before starting work in any environment, always pull the latest state from GitHub.

  • Starting locally:
    • Run git pull origin main first to get the latest remote changes.
  • Starting on Colab:
    • Don't just use an old browser tab. Go to File > Open notebook > GitHub tab to explicitly re-open the latest commit.

2. "Save" When You Finish​

Once your edits are done, always push your work back to GitHub as a "hand-off."

  • Local edits: Don't forget to git push.
  • Colab edits: Run File > Save a copy in GitHub. If you close the browser without doing this, your Colab changes will be lost.

3. Avoid Simultaneous Editing​

To prevent messy conflicts, do not edit the same file in multiple environments at the same time. Strictly follow the "Push from Local β†’ Open in Colab" or "Save from Colab β†’ Pull to Local" relay.

4. Handling Conflicts​

If a conflict occurs, it is easiest to resolve it in your local environment (VSCode/Cursor). These editors have built-in conflict resolution tools that allow you to visually compare and choose which changes to keep.

Conclusion​

By following this setup, you create a powerful development environment that leverages the best of all worlds:

  • GitHub: Reliable version control and history.
  • Local Editors (VSCode/Cursor): High-speed coding with AI and rich extensions.
  • Google Colab: On-demand cloud GPU/TPU resources.

By following these simple operational rules, you can minimize conflict risks while enjoying a flexible and professional development workflow.

If this site helped you, please support us with a star! 🌟
Star on GitHub

References​