> For the complete documentation index, see [llms.txt](https://docs.bdb.ai/data-science-lab-4/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.bdb.ai/data-science-lab-4/project/tabs-for-a-data-science-lab-project/tabs-for-tensorflow-and-pytorch-environment/notebook/ways-to-access-notebook/import/pull-from-git.md).

# Pull from Git

This functionality is provided for pulled Notebooks. The users need to start with initial Pull from the Git repository to proceed with this functionality.

## Pulling from Git

{% hint style="warning" %}
*<mark style="color:orange;">Pre-requisite:</mark>*&#x20;

* *The user needs to do the **Admin configuration** with an authentication token.*&#x20;
* *The user must also do **Project** level- configuration of **Git Project** and **Git branch**.*
  {% endhint %}

{% hint style="info" %}
*<mark style="color:green;">Please Note:</mark> the user can generate an authentication token from their Git Lab or Git Hub repositories.*
{% endhint %}

### Admin Level Configuration

{% hint style="success" %}
*Check out the given illustration to understand the Admin configuration part with the authentication token under the platform.*
{% endhint %}

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBLGYLEkBUnc8nVEBAuEI%2Fuploads%2FFFMLRA7479lmqVVIIsFb%2FGit%20pull_Prerequisites.mp4?alt=media&token=a28d7d95-6fef-469e-8e0d-233e5fed1132>" %}
***Pull Pre-requisite***
{% endembed %}

* Navigate to the ***Admin*** module.
* Open the ***Version Control*** from the ***Configuration*** options.
* Select the Token type as a private token.
* Provide the authentication token in the given space.
* Click the ***Test*** option.

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/N8HCjcAiX1pqt4Ep6iz5/image.png" alt=""><figcaption></figcaption></figure>

* A notification message appears to inform the user that authentication has been established.
* Click the ***Save*** option.&#x20;

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/fJrtu2MBlYxm68jXO1Hk/image.png" alt=""><figcaption></figcaption></figure>

* A notification message appears to inform that the version control has been updated.

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/la6GIspUwRhShmJKGONh/image.png" alt=""><figcaption></figcaption></figure>

### Pulling a file from Git&#x20;

Projects and Branches created in GitLab/GitHub can be accessed using the access token inside the DS Lab and the files (.ipynb) can be pulled using the ***Pull from Git*** functionality.

Once the initial pull (import) has happened, the user can pull the latest version of the Python file from Git using the Pull from VCS functionality available in the Notebook List.

{% hint style="info" %}
*<mark style="color:green;">Please Note:</mark> Only .ipynb files will be supported.*
{% endhint %}

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBLGYLEkBUnc8nVEBAuEI%2Fuploads%2FQyAC0WhNDRJm5KfqXfwz%2FGit%20Pull_Notebook.mp4?alt=media&token=194b6ebe-d572-4666-8e06-aab2a88f82d1>" %}
***Pulling from Git***&#x20;
{% endembed %}

* Navigate to an activated Project.
* Open the ***Notebook*** tab (It opens by default).
* Click the ***Import*** option.

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/8Ri8tEZQvokKdiwOcvB8/image.png" alt=""><figcaption></figcaption></figure>

* The Import Notebook page opens.
* Select the ***Pull from Git*** option.
* All the available versions appear.
* Click the ***Save*** option.

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/bWnKOC5gEJR9CWgFqOW3/image.png" alt=""><figcaption></figcaption></figure>

* A notification message appears to ensure that the selected file is pulled.

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/uHf1bKCKa7QrjmjDAPGa/image.png" alt=""><figcaption></figcaption></figure>

* Consecutive notifications appear to ensure that the Notebook is started, imported, and saved.

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/J13Rx2PWXLfz26Qa3pB7/image.png" alt=""><figcaption></figcaption></figure>

* Access the Notebook script from the Git repository.

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/qLl46vKTwxcRaK24vYOj/image.png" alt=""><figcaption></figcaption></figure>

* Open the same script from Git.
* Click the ***Edit*** option.

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/PFWfF8pyzbwttKm5LMFf/image.png" alt=""><figcaption></figcaption></figure>

* The script opens in ***Edit file*** mode.
* Modify the script.

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/Oc1bMmkeaIuX1hndKkvp/image.png" alt=""><figcaption></figcaption></figure>

* Click the ***Commit changes*** option.

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/sbaknhKKRFF5r3OekwCw/image.png" alt=""><figcaption></figcaption></figure>

* A notification message appears to ensure that the changes are successfully committed.

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/xEPjcLUhdXu4wz7asj2w/image.png" alt=""><figcaption></figcaption></figure>

* The modification committed in the script gets saved.

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/JP6TPZsQIiF23L13gwOn/image.png" alt=""><figcaption></figcaption></figure>

* Navigate to the same Notebook.
* Click the ellipsis icon to get the Notebook options.
* Click the ***Pull from VCS*** option.

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/4oMMmU8Ey6LowDBlaYfx/image.png" alt=""><figcaption></figcaption></figure>

* The ***Pull from Git*** dialog box opens.
* Click the ***Yes*** optio*n*.

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/WUWigCUcJWl6GajpwscH/image.png" alt=""><figcaption></figcaption></figure>

* A notification message appears to inform the user that the latest file version is pulled.

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/61AO0f7ED93Xb3drJd4j/image.png" alt=""><figcaption></figcaption></figure>

* Another notification message appears to inform the user that the pulled Notebook is started.
* The latest/ modified script gets updated.

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/ShWbORlJd1h1j8hzP2ae/image.png" alt=""><figcaption></figcaption></figure>

## Pushing to Git

### Related Settings for the Git Token

{% hint style="warning" %}
*<mark style="color:orange;">Push pre-requisites:</mark>*

1. The user branch should have Developers' + maintainers' permission to push the latest code into the **Main** branch.
2. The User token has to be set in the user profile using the Custom Fields setting available at the Admin level.
3. The user token key name has to be '**bdbvcstoken'**.
   {% endhint %}

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBLGYLEkBUnc8nVEBAuEI%2Fuploads%2FzVipXaBuZAuJB6124vDG%2FGit%20push_Prerequisites.mp4?alt=media&token=c0aa8561-d7a5-4cd6-98ab-e3ae872fe968>" %}
***Pre-requisites for Pushing a file to Git***
{% endembed %}

* Navigate to the Admin module.
* Open the ***Custom Field Settings*** under the configurations option.
* The Custom Field Information appears.
* Provide the following information for custom field:
  * Key- ***bdbvcstoken***
  * &#x20;Input type *- Manual*
  * Description - Git User Token
  * &#x20;*Mandatory - No*
* Click the ***Save*** option to save the modified ***Custom Field Settings***.
* A notification message appears to inform the user that the custom field settings are updated.

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/co0v3VNueTqhhwCcE3dw/image.png" alt=""><figcaption></figcaption></figure>

* Navigate to the ***Security*** module.
* Go to the ***Users*** list.
* Select the user from the list.
* Click the ***Edit*** icon.

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/vBJrH95CNJoRt2C6ogH8/image.png" alt=""><figcaption></figcaption></figure>

* The ***Update User*** page opens.
* Check out the ***Custom Fields*** section.&#x20;
* ***Validate*** whether the ***Git User Token*** is valid or not. If not ***provide the valid Git User Token***.
* Click the ***Save*** option.

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/WNuLmXcwDPQ7cu5lAxBS/image.png" alt=""><figcaption></figcaption></figure>

* A notification message appears to inform that the user is updated successfully.

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/cS1UHZw1qALGlIVcm5fw/image.png" alt=""><figcaption></figcaption></figure>

* Open the ***User Profile***.
* Select the ***My Account*** option.

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/FpBadJj6xVO4vSRBd2Vu/image.png" alt=""><figcaption></figcaption></figure>

* The ***My Account*** details are displayed.
* Open the ***Configuration*** option.

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/9M2b9VgqaXbImzhg9PLc/image.png" alt=""><figcaption></figcaption></figure>

* The same token gets updated under the ***Git Token*** section which was provided under the ***Configuration*** section.

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/1tOoFmLQCaBvFRESAcGb/image.png" alt=""><figcaption></figcaption></figure>

### Pushing a File to Git

{% hint style="info" %}
*<mark style="color:green;">Please Note:</mark> Before using the Push a file to Git functionality make sure that the following requirements are fulfilled:*

1. *The latest file is pulled into DS Lab before modifying and pushing back to the Git branch.*&#x20;
2. *The user should have access to the Git branch for pushing a change.*
   {% endhint %}

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBLGYLEkBUnc8nVEBAuEI%2Fuploads%2Fi6IqKvLZdQTJeTxevCfK%2FGit%20Push_Notebook.mp4?alt=media&token=013385b6-bdd8-44f0-8601-80e0717f8d43>" %}
***Pushing to Git***
{% endembed %}

* Open an activated Project.
* Navigate to the Notebook tab (it opens by default).
* Select a Notebook from the displayed list to open the content/script.
* The existing content gets displayed. Carefully notice the script version.

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/73XGrUr5uyIpF44tl0mD/image.png" alt=""><figcaption></figcaption></figure>

* Click the ellipsis icon to get the notebook options.
* Click the Push into VCS option for the selected Notebook.

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/hb2ELqOLwNAqY8x0A5Ey/image.png" alt=""><figcaption></figcaption></figure>

* The ***Push into Git*** dialog box opens.
* Provide a commit message.
* Click the ***Push*** option.

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/wF5PIIR8n9vCzseIHjj4/image.png" alt=""><figcaption></figcaption></figure>

* A notification message appears to ensure that the latest file version is pushed (to Git).

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/NQV7tAxO9AHCL8Mn0S0a/image.png" alt=""><figcaption></figcaption></figure>

* Navigate to the Git repository and access the pushed version of the Notebook script.

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/GEunyBLhIMhz4vf9KPbR/image.png" alt=""><figcaption></figcaption></figure>

* Open the script.
* Click the ***Edit*** option.

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/zUK9N6WVgSvIjAJZuKKl/image.png" alt=""><figcaption></figcaption></figure>

* The file opens in Edit mode.
* Modify the script. E.g., In the given image the version number is changed from V1 to V2.

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/EwkY86AHgcQVPaLU63Ep/image.png" alt=""><figcaption></figcaption></figure>

* Click the ***Commit changes*** option.

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/ki6u8sEZYo6kuKOW2Tn1/image.png" alt=""><figcaption></figcaption></figure>

* A message appears to ensure that your changes have been successfully committed.

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/8XsYpkbydyeAnENA3AbY/image.png" alt=""><figcaption></figcaption></figure>

* Navigate back to the same Notebook.
* Verify the script content. E.g., the below-given image displays that the selected Notebook has an older version mentioned.
* Click the ellipsis icon to get the Notebook options.
* Click the ***Push into VCS*** option.

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/E4I7se0qAJmmzrqtTjEN/image.png" alt=""><figcaption></figcaption></figure>

* The ***Push into Git*** dialog box appears.
* Provide a Commit Message.&#x20;
* Click the ***Push*** option.

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/qCySxn53UaqA2RRsu9Rb/image.png" alt=""><figcaption></figcaption></figure>

* An error message appears suggesting to take the latest pull since the currently existing file does not contain the latest update.

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/b63msgPteJr6GT5TQPPs/image.png" alt=""><figcaption></figcaption></figure>

* Click the ellipse icon for the same Notebook.
* Click the ***Pull from VCS*** option from the displayed menu

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/IxcrWdINPJWqUVDXW6jC/image.png" alt=""><figcaption></figcaption></figure>

* The ***Pull from Git*** dialog box opens.
* Click the ***Yes*** option to pull the latest file version from Git.

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/JhfrtZwdiYpY5FUaB3Xh/image.png" alt=""><figcaption></figcaption></figure>

* A notification message appears to notify that the latest file version has been pulled.

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/5oqnYWirvt7dARbCCLXW/image.png" alt=""><figcaption></figcaption></figure>

* Navigate to the same Notebook.
* Check out the Notebook script, the latest modifications will be reflected in the script. E.g., In this case, the updated version appears in the script.&#x20;

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/ytMZSWbWixQWjUJGZiSm/image.png" alt=""><figcaption></figcaption></figure>

* Modify the available script inside the Notebook. E.g., Again the Version of the script has been changed to V3.
* Click the ***Save*** icon to save the changes.

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/FdQnf385heCotHdiFjfc/image.png" alt=""><figcaption></figcaption></figure>

* A notification message appears to ensure that the Notebook has been successfully saved.
* Click the ellipsis icon to open the Notebook options.
* Click the ***Push into VCS*** option from the displayed list of options.

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/kwi06YnarLB8jJ5MP6hN/image.png" alt=""><figcaption></figcaption></figure>

* The ***Push into Git*** dialog box opens.
* Provide a commit message.
* Click the ***Push*** option.

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/bvHaaXmWyJUzuR0BhlBR/image.png" alt=""><figcaption></figcaption></figure>

* A success notification message appears ensuring that the latest file version has been pushed to Git.

<figure><img src="https://content.gitbook.com/content/1QeOywZjV1cHo55cMW8u/blobs/QoYh6OoeTPfHUanTafzm/image.png" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
*<mark style="color:green;">Please Note:</mark>*&#x20;

* *The Pull from Git functionality supports **Git Lab** and **Git Hub**.*
* *Refer to the* [***Data Science Lab Quick Start Flow***](https://docs.bdb.ai/data-science-lab-4/data-science-lab-quick-start-flow) *page to get an overview of the **Data Science Lab** module in a nutshell.*&#x20;
  {% endhint %}
