Introducing GitPlus: Version Control extension for Jupyter

1 minute read

There’s no easy way to version control notebooks from Jupyter UI. Of course you can drop down to command line & learn a bunch of git commands to version control your notebooks. But not everyone using Jupyter needs to be proficient at git. Hence I built GitPlus, a JupyterLab extension that provides the ability to commit notebooks & create GitHub pull requests directly from JupyterLab UI.

How to version control Jupyter Notebooks

When GitPlus extension is installed, it provides a new menu item Git-Plus in JupyterLab UI. From there, you can commit notebook files or create a GitHub pull request as shown in demo videos below.

  • Create GitHub Pull Request from Jupyter
  • Create & push GitHub commits from Jupyter

How does it work?

  • There’s a server component of the extension that uses gitpython & GitHub APIs to push commits and create pull requests.
  • There’s a client component of the extension that provides the UI and calls appropriate endpoint on the server extension.
  • The client component looks at all the open files in JupyterLab and determines which of those files are under a GitHub repository.
  • It lets you select the repository to which you want to push commit or create pull request.
  • It captures the list of files to commit, commit message and pushes the changes as a commit to remote repository.
  • In case of pull requests, it creates a new branch and pushes the changes there. This newly created branch is compared to default branch (typically master branch) of your repository.
  • In case of forked repositories, pull request is created on the parent repository.

Installation

Here are the installation instructions.

Limitation

As of now, GitPlus only works with JupyterLab. If you are interested in using it with classic Jupyter UI, please upvote this feature request. I’d like to work on this only if there’s enough interest.

Roadmap

In future GitPlus will be able to,

  • Pull changes from GitHub
  • Switch/create git branches locally
  • Resolve notebook merge conflicts (without messing with underlying JSON)

Conclusion

If you are new to Git, it can take some time to get used to all the commands. Even if you are comfortable with git, notebook JSON can create unintended side effects. GitPlus provides easy-to-use interface to accomplish most common git tasks from JupyterLab UI. You can combine it with ReviewNB to see visual diffs & write comments on notebook changes.

Happy Hacking!