Using the Git Plug-in

For notebook instances with the GitHub code library, you can use the Git plug-in on the JupyterLab page to quickly view the content and submit the modified code.

Prerequisites

A notebook instance with a Git repository has been created and is in the Running state.

Opening the Git Plug-in of JupyterLab

  1. In the notebook instance list, select an instance with a Git repository and click the name to open the notebook instance.
  2. On the Jupyter page, click Open JupyterLab in the upper right corner. The JupyterLab page is displayed.

    Figure 1 shows the Git plug-in of JupyterLab.

    Figure 1 Git plug-in

Viewing Code Library Information

In the list under Name, double-click the folder you want to use and click the Git plug-in icon on the left to access the code library corresponding to the folder.

Figure 2 Opening the folder and starting the Git plug-in
You can view the information about the current code library, such as the repository name, branch, and historical submission records.
Figure 3 Viewing code library information

Viewing Content Changes

If you modify a file in the code library, you can view the modified file under Changed on the Changes tab page. You can click Diff this file on the right of the file name to view the changes to the file content.

Figure 4 Viewing content changes

Committing Content Changes

After confirming that the changes are correct, click Stage this change (equivalent to running the git add command) on the right of the file name. The file enters the Staged state. Enter the message to be committed in the lower left corner and click Commit (equivalent to running the git commit command).

Figure 5 Committing content changes

On the History tab page, you can see that the committing is successful.

Figure 6 Checking whether the committing is successful

Clicking the push button is equivalent to running the git push command to push the code to the GitHub repository. After the pushing is successful, the message "Git Push completed successfully" is displayed. If the token used for OAuth authentication has expired, a dialog box is displayed asking you to enter the user token or account information. Enter the information as prompted.

Figure 7 Pushing code to the GitHub repository

After the preceding operations are completed, on the History tab page of the Git plug-in page of JupyterLab, you can see that origin/HEAD and orgin/master point to the latest push. In addition, you can find the corresponding information in the committing records of the GitHub repository.