# Pull from Git

You can bring your Python script to the Notebook framework to carry forward your Data Science experiment.

The Import functionality contains two ways to import a Notebook.

* [Import Notebook](https://app.gitbook.com/o/BHXEmSpD7W3xDgxnOIpk/s/z33KQNYQvBTgQKJBgwTz/~/changes/20/tabs-for-a-dsl-project/workspace/working-with-the-workspace-tab/import/importing-notebook)
* Pull from Git

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

## Pulling from Git

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

* *The user needs to do an **Admin configuration** with an authentication token.*&#x20;
* *The user must also need to do **Project-level**- configuration of **Git Project** and **Git branch**.*
* The user needs to Pull a version of the file from Git before using the Pull and Push functionality for the projects where the source files are available in Git Repo.
  {% 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/z33KQNYQvBTgQKJBgwTz/blobs/VHNJkZctjQWb0GGMd81b/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/z33KQNYQvBTgQKJBgwTz/blobs/ilJSYbfP4F07NINuRlgV/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/z33KQNYQvBTgQKJBgwTz/blobs/pdSCbVAwVO8xwZZyiL7a/image.png" alt=""><figcaption></figcaption></figure>

### Pulling a file from Git

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.

{% hint style="success" %}
*Check out the given illustration to understand the **Pull from Git** functionality.*
{% endhint %}

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fz33KQNYQvBTgQKJBgwTz%2Fuploads%2F9NqjT3eSIwxs6GqPjeZw%2FNormal_Pull%20from%20Git.mp4?alt=media&token=756a1ef9-9a76-4f73-a762-a27ec9791f72>" %}
***Pull from Git***
{% endembed %}

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.

* 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/z33KQNYQvBTgQKJBgwTz/blobs/RqQxdU73VpqBjp6zvUBg/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/z33KQNYQvBTgQKJBgwTz/blobs/FyMPahTySXlakM55nScM/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/z33KQNYQvBTgQKJBgwTz/blobs/V8fJukSB8gkkq55FiTzT/image.png" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://content.gitbook.com/content/z33KQNYQvBTgQKJBgwTz/blobs/7XfmmD4mTgMS7k9d6ZcG/image.png" alt=""><figcaption></figcaption></figure>

* Access the Notebook script from the Git repository.

<figure><img src="https://content.gitbook.com/content/z33KQNYQvBTgQKJBgwTz/blobs/Tvtmnu2FBWFiqOhoUK0t/image.png" alt=""><figcaption></figcaption></figure>

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

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

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

<figure><img src="https://content.gitbook.com/content/z33KQNYQvBTgQKJBgwTz/blobs/X5x3DRyTTrO7itzougsr/image.png" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://content.gitbook.com/content/z33KQNYQvBTgQKJBgwTz/blobs/hT4apolPD8X8j7QQ2FkQ/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/z33KQNYQvBTgQKJBgwTz/blobs/I7D6HexFaFXxCxgnTLN1/image.png" alt=""><figcaption></figcaption></figure>

* The modification committed in the script gets saved.

<figure><img src="https://content.gitbook.com/content/z33KQNYQvBTgQKJBgwTz/blobs/N5KrAonbGgBeD00kLixF/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/z33KQNYQvBTgQKJBgwTz/blobs/i5Jml08ay0QQhAI13nGS/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/z33KQNYQvBTgQKJBgwTz/blobs/REcXkB7td2ZswPeWXWqI/image.png" alt=""><figcaption></figcaption></figure>

* A notification informs the user that the latest file version is pulled.

<figure><img src="https://content.gitbook.com/content/z33KQNYQvBTgQKJBgwTz/blobs/cFfodZLhjmZa2xijPXXE/image.png" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://content.gitbook.com/content/z33KQNYQvBTgQKJBgwTz/blobs/5xXzfz84NIHsDYd5H09k/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' and 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 the 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/z33KQNYQvBTgQKJBgwTz/blobs/OjX8Eb2yEcEmjVi2gozH/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/z33KQNYQvBTgQKJBgwTz/blobs/7RbcCXfXgoa2uRtPl2UR/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/z33KQNYQvBTgQKJBgwTz/blobs/J2Mv4FBreC5u7ABD0jby/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/z33KQNYQvBTgQKJBgwTz/blobs/uStwbIvc3rD8NdQYItuC/image.png" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://content.gitbook.com/content/z33KQNYQvBTgQKJBgwTz/blobs/6MkSEGtNSjtG7NK3bWeq/image.png" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://content.gitbook.com/content/z33KQNYQvBTgQKJBgwTz/blobs/tiPDPVF0YkdU5YCmv3hF/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/z33KQNYQvBTgQKJBgwTz/blobs/fteqTmo4KhHvv8kKzSr4/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%2Fz33KQNYQvBTgQKJBgwTz%2Fuploads%2FHCz6U9ghCpIVqKyilFVk%2FNormal_Push%20into%20Git.mp4?alt=media&token=468212b1-140a-4bce-917a-b1360a1ac538>" %}
***Pushing to Git***
{% endembed %}

* Navigate to the ***Workspace*** tab (it opens by default) for an activated project.
* Select a Notebook from the displayed list to open the content/script.
* The existing content gets displayed.&#x20;

<figure><img src="https://3817372244-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fz33KQNYQvBTgQKJBgwTz%2Fuploads%2F0vAYrZpkVlN4uiRlZyG2%2Fimage.png?alt=media&#x26;token=9b1d71ee-700f-4af4-8135-9484aa368b9e" alt=""><figcaption></figcaption></figure>

* Modify the script to create a new version of the Notebook.
* Click the ***Save*** icon to save the latest of the Notebook.

<figure><img src="https://3817372244-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fz33KQNYQvBTgQKJBgwTz%2Fuploads%2FM21uuQU7tgzREttcl4nc%2Fimage.png?alt=media&#x26;token=d30f8f0d-e82d-41b3-bdde-c63625f67002" alt=""><figcaption></figcaption></figure>

* A notification ensures that the Notebook is saved.
* Click the ***Push into VCS*** option from the Notebook options.

<figure><img src="https://3817372244-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fz33KQNYQvBTgQKJBgwTz%2Fuploads%2Fz2pmlWyX41U7K6X4Y27r%2Fimage.png?alt=media&#x26;token=6847514c-9149-4b41-8955-a276151000f3" alt=""><figcaption></figcaption></figure>

* The ***Push into Git*** drawer opens.
* Select the ***Version control*** option.
* Provide a commit message.
* Click the ***Push*** option.

<figure><img src="https://3817372244-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fz33KQNYQvBTgQKJBgwTz%2Fuploads%2FWwsqNSSIiyXZyvKmAmLG%2Fimage.png?alt=media&#x26;token=5c68840b-eed3-408c-8175-c29c101ad494" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://3817372244-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fz33KQNYQvBTgQKJBgwTz%2Fuploads%2FioRimu4r6MmuyMRbEUIw%2Fimage.png?alt=media&#x26;token=c9aa5baa-f2df-4b7b-beb6-d6fec1a2687d" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://3817372244-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fz33KQNYQvBTgQKJBgwTz%2Fuploads%2F2AYxpSYileHaLO7WG519%2Fimage.png?alt=media&#x26;token=6745ac10-a285-4f3a-8799-c9c36f0f9dd2" alt=""><figcaption></figcaption></figure>

* Open the script. The latest changes will be reflected in the script.

<figure><img src="https://3817372244-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fz33KQNYQvBTgQKJBgwTz%2Fuploads%2FFyEl7cGrjJ5cqkxr7bqW%2Fimage.png?alt=media&#x26;token=e9937292-df62-407e-8b45-2fbda1f00097" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
*<mark style="color:green;">Please Note:</mark> The* **Pull from Git** *functionality supports **Git Lab** and **Git Hub**.*
{% endhint %}

## Pull & Push Functionality for Repo Sync Projects

### Pull from Git

{% hint style="success" %}
*Check out the illustration explaining the Pull from Git functionality for a Repo Sync Project.*
{% endhint %}

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fz33KQNYQvBTgQKJBgwTz%2Fuploads%2FCkLaWnOR51VuWLWuLj8S%2FRepo_Pull%20from%20Git.mp4?alt=media&token=a99a3893-7d16-4a88-ba9a-c399aa6dfd61>" %}
***Pull from Git for Repo Sync Project***
{% endembed %}

### Push into Git

{% hint style="success" %}
*Check out the illustration explaining the Push into Git functionality for a Repo Sync Project.*
{% endhint %}

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fz33KQNYQvBTgQKJBgwTz%2Fuploads%2F5NTNFyi9tqZmxl9wiQrP%2FRepo_Push%20into%20Git.mp4?alt=media&token=6c9bd678-1e0d-40b6-b223-32e4ebacbb7c>" %}
***Pull into Git for Repo Sync Project***
{% endembed %}
