Skip to main content

A server extension for JupyterLab's git extension

Project description

jupyterlab-git

Binder Github Actions Status Version Version Downloads Version Downloads All Contributors

A JupyterLab extension for version control using Git

ui_glow_up

To see the extension in action, open the example notebook included in the Binder demo.

Prerequisites

  • JupyterLab (version ~=1.1)
  • Git (version >=2.x)

Usage

  • Open the Git extension from the Git tab on the left panel

Install

To install perform the following steps:

pip install --upgrade jupyterlab-git
jupyter lab build

Settings

UI Settings

Once installed, extension behavior can be modified via the following settings which can be set in JupyterLab's advanced settings editor:

  • blockWhileCommandExecutes: suspend JupyterLab user interaction until Git commands (e.g., commit, pull, reset, revert) finish executing. Setting this to true helps mitigate potential race conditions leading to data loss, conflicts, and a broken Git history. Unless running a slow network, UI suspension should not interfere with standard workflows. Setting this to false allows for actions to trigger multiple concurrent Git actions.
  • cancelPullMergeConflict: cancel pulling changes from a remote repository if there exists a merge conflict. If set to true, when fetching and integrating changes from a remote repository, a conflicting merge is canceled and the working tree left untouched.
  • disableBranchWithChanges: disable all branch operations, such as creating a new branch or switching to a different branch, when there are changed/staged files. When set to true, this setting guards against overwriting and/or losing uncommitted changes.
  • displayStatus: display Git extension status updates in the JupyterLab status bar. If true, the extension displays status updates in the JupyterLab status bar, such as when pulling and pushing changes, switching branches, and polling for changes. Depending on the level of extension activity, some users may find the status updates distracting. In which case, setting this to false should reduce visual noise.
  • doubleClickDiff: double click a file in the Git extension panel to open a diff of the file instead of opening the file for editing.
  • historyCount: number of commits shown in the history log, beginning with the most recent. Displaying a larger number of commits can lead to performance degradation, so use caution when modifying this setting.
  • refreshInterval: number of milliseconds between polling the file system for changes. In order to ensure that the UI correctly displays the current repository status, the extension must poll the file system for changes. Longer polling times increase the likelihood that the UI does not reflect the current status; however, longer polling times also incur less performance overhead.
  • simpleStaging: enable a simplified concept of staging. When this setting is true, all files with changes are automatically staged. When we develop in JupyterLab, we often only care about what files have changed (in the broadest sense) and don't need to distinguish between "tracked" and "untracked" files. Accordingly, this setting allows us to simplify the visual presentation of changes, which is especially useful for those less acquainted with Git.

Server Settings

  • Post git init actions: It is possible to provide a list of commands to be executed in a folder after it is initialized as Git repository.
{
  "JupyterLabGit": {
    "actions": {
      "post_init": [
        "touch dummy_init.dat"
      ]
    }
  }
}

Troubleshooting

Before consulting the following list, be sure the server extension and the frontend extension have the same version by executing the following commands:

jupyter serverextension list
jupyter labextension list
  • Issue: the Git panel does not recognize that you are in a Git repository.

    Possible fixes:

    • Be sure to be in a Git repository in the filebrowser tab

    • Check the server log. If you see a warning with a 404 code similar to: [W 00:27:41.800 LabApp] 404 GET /git/settings?version=0.20.0

      Explicitly enable the server extension by running:

      jupyter serverextension enable --py jupyterlab_git
      
    • If you are using JupyterHub or some other technologies requiring an initialization script which includes the jupyterlab-git extension, be sure to install both the frontend and the server extension before launching JupyterLab.

  • Issue: the Git panel is not visible.

    Possible fixes:

    • Check that the JupyterLab extension is installed:

      jupyter labextension list
      

      If you don't see @jupyterlab/git v... enabled OK in the list, explicitly install the jupyter labextension by running:

      jupyter labextension install @jupyterlab/git
      

Development

Contributing

If you would like to contribute to the project, please read our contributor documentation.

JupyterLab follows the official Jupyter Code of Conduct.

Install

Requires node 10+

# Install new-ish JupyterLab
pip install -U jupyterlab

# Clone the repo to your local environment
git clone https://github.com/jupyterlab/jupyterlab-git.git
cd jupyterlab-git

# Install the server extension in development mode and enable it
pip install -e .[test]
jupyter serverextension enable --py jupyterlab_git --sys-prefix

# Build the labextension and dev-mode link it to jlab
jlpm
jupyter labextension link .

To rebuild the package after a change and the JupyterLab app:

jlpm run build
jupyter lab build

To continuously monitor the project for changes and automatically trigger a rebuild, start Jupyter in watch mode:

jupyter lab --watch

And in a separate session, begin watching the source directory for changes:

jlpm run watch

Now every change will be built locally and bundled into JupyterLab. Be sure to refresh your browser page after saving file changes to reload the extension (note: you'll need to wait for webpack to finish, which can take 10s+ at times).

To execute the tests

pytest jupyterlab_git
jlpm run test

Contributors โœจ

The Jupyter Git extension is part of Project Jupyter and is developed by an open community of contributors. To see who has been active recently, please look at the "Contributors" tab. Below we list the people and entities who contributed in different ways to the project (emoji key):


Amazon Web Services

๐Ÿ’ต

Ashutosh Bondre

๐Ÿ’ป ๐Ÿ‘€

Athan

๐Ÿ’ป ๐Ÿ‘€ ๐Ÿ“† ๐ŸŽจ

Brian E. Granger

๐Ÿ“† ๐ŸŽจ ๐Ÿค” ๐Ÿ”

Frรฉdรฉric Collonval

๐Ÿšง

Hana Zarea

๐Ÿ’ป ๐Ÿ‘€

Jaipreet Singh

๐Ÿ“† ๐Ÿ‘€ ๐Ÿ’ป ๐ŸŽจ

Ji Zhang

๐Ÿ’ป ๐Ÿ‘€

Konstantin Taletskiy

๐Ÿ’ป ๐Ÿ‘€

Max Klein

๐Ÿ’ป ๐Ÿ‘€ ๐Ÿ“† ๐ŸŽจ ๐Ÿš‡

Neelam Gehlot

๐Ÿ’ป ๐Ÿ‘€

Noah Stapp

๐Ÿ’ป ๐Ÿ‘€

Saul Shanabrook

๐Ÿ’ป ๐Ÿ“† ๐Ÿ‘€ ๐Ÿš‡

The D. E. Shaw Group

๐Ÿ’ต

jupytercalpoly

๐Ÿ’ต

This project follows the all-contributors specification. Contributions of any kind welcome!

To add yourself, or someone else, to this list you can either use the bot (@all-contributors please add <username> for <contributions>) or the CLI (jlpm all-contributors add <username> <contributions>).

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jupyterlab_git-0.11.0rc1.tar.gz (254.6 kB view details)

Uploaded Source

Built Distribution

jupyterlab_git-0.11.0rc1-py3-none-any.whl (253.6 kB view details)

Uploaded Python 3

File details

Details for the file jupyterlab_git-0.11.0rc1.tar.gz.

File metadata

  • Download URL: jupyterlab_git-0.11.0rc1.tar.gz
  • Upload date:
  • Size: 254.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for jupyterlab_git-0.11.0rc1.tar.gz
Algorithm Hash digest
SHA256 f97e381d6603e4701553cc4402fcdb5740580cf89087a43ed4b628d727083a0f
MD5 230596afeca43768d7ee60c51f0c682e
BLAKE2b-256 16a3bcc9d0f53442bdef188437ecbad8f3a5cae438e092e3f9d26c0b53329169

See more details on using hashes here.

File details

Details for the file jupyterlab_git-0.11.0rc1-py3-none-any.whl.

File metadata

  • Download URL: jupyterlab_git-0.11.0rc1-py3-none-any.whl
  • Upload date:
  • Size: 253.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for jupyterlab_git-0.11.0rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 cb5019945c48c50375bfacd403817831fc45177c919d89091f4c5ecf8ed00e55
MD5 14837dc1be5a8a66f9eaf35b996393d3
BLAKE2b-256 fea5be53ef7df12546b68227133a2686797f4d8886addd89b2290ba80a7f431d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page