# Git Console

## Using Git Console

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QeOywZjV1cHo55cMW8u%2Fuploads%2F5unb2c2G2K4Ow3EWyBgO%2FConsole%20%26%20Conflict%20changes.mp4?alt=media&token=cd6e4e9e-e768-440f-b4f6-f85cb985e7c1>" %}

* Navigate to the ***Notebook*** tab of an activated Repo Sync Project.
* Select a .ipynb file from the ***Repo Sync*** Project.
* The file content opens.

<figure><img src="/files/0iZFsQTdJ4k19ilOZAoJ" alt=""><figcaption></figcaption></figure>

* Edit the displayed script.
* Click the ***Save*** icon.

<figure><img src="/files/DgyhrI2DF6WfGKhzkggC" alt=""><figcaption></figcaption></figure>

* A notification message appears to ensure that the script has been saved.

<figure><img src="/files/tptLBA3vAfgETkIXQV3p" alt=""><figcaption></figcaption></figure>

* Navigate to Git Repository.
* Access the same script on the Git Repository.

<figure><img src="/files/2SpGhuhUBPVm5F7i5YfG" alt=""><figcaption></figcaption></figure>

* Click the ***Edit*** tab to open the script in the editable format.
* Modify or change the existing script.
* Click the ***Commit changes*** option.

<figure><img src="/files/N4pGrRyUCOWgA8x9pXAs" alt=""><figcaption></figcaption></figure>

* The ***Commit changes*** window opens.
* Provide a ***Commit message and choose a branch to commit your changes.***
* Click the ***Commit changes*** option.

<figure><img src="/files/MQjKeRB66SzjoDBOTmRo" alt=""><figcaption></figcaption></figure>

* Your changes get commited to the script.

<figure><img src="/files/hFXZSOR7ZHazNtt6S1v7" alt=""><figcaption></figcaption></figure>

* Navigate to the DSL repo sync project and click the ***Console*** icon.
* The ***Git Console*** space opens.
* Use the Git commands to get the latest updates for the script.
  * git status, git add, and git commit commands are used in the given image:

<figure><img src="/files/VDKwXtJXQU6TfeuobycN" alt=""><figcaption></figcaption></figure>

* The next used Git command is **git push.**
* The displayed warning in the given image indicates that the push command is rejected as the remotely saved script has some recent changes, therefore the user is advised to first pull the remote changes before pushing the script.

<figure><img src="/files/a8HRgGJWa6QQbWt3pEmE" alt=""><figcaption></figcaption></figure>

* The below given image displays the Pull command used in the Git space.
* The ending lines indicates that there is conflict in the selected script, so the user must fix the conflict and merge the result.

<figure><img src="/files/R6DUwwfm7pdIyZuTqsRB" alt=""><figcaption></figcaption></figure>

* The file title appears in red color to indicate the conflict.
* The cells containing conflicted content get highlighted in the script.

<figure><img src="/files/aSRa8Up9ruIowyTjcHOB" alt=""><figcaption></figcaption></figure>

* Click the ***Delete*** icon for the conflicted cells.
* The ***Delete Cell*** window appears.
* Click the ***Yes*** option.

<figure><img src="/files/6avDu2B13VWyQEBSRbfe" alt=""><figcaption></figcaption></figure>

* A notification message appears to ensure that the conflicted cell is removed from the script.
* Click the ***Save*** icon for the script.

{% hint style="info" %}
*<mark style="color:green;">Please Note:</mark> The user must resolve all the conflicts in the selected file, before saving it.*
{% endhint %}

<figure><img src="/files/4jrGCPADUGHaI89lk8uy" alt=""><figcaption></figcaption></figure>

* A notification message appears to ensure that the script is saved.
* The saved script reflects the remote changes.

<figure><img src="/files/pbur9UTBiVr96ePG455e" alt=""><figcaption></figcaption></figure>

* The color of the selected file title also gets changed.
* By hovering on the file name, it displays the current status of the file. E.g., the given image displays that for the current file conflicts are resolved, but it is in uncommitted status.

<figure><img src="/files/nHQY6qg6QArQ29iIUHs1" alt=""><figcaption></figcaption></figure>

* Click the ***Git*** ***Console*** icon.
* The ***Git Console*** space gets displayed.
* The used Git commands in the given example are git add, git commit, and git push.

<figure><img src="/files/Q1vLtB61aCIqOr2OuWtO" alt=""><figcaption></figcaption></figure>

* Navigate to the script saved remotely (in the Git repository).
* The script displays the recent changes committed by using the Git Console space for a Repo Sync Project.

<figure><img src="/files/WFxAbo1yzxqMwzmq9kO5" alt=""><figcaption></figcaption></figure>

## Commonly used Git Commands

*All the Git commands will be supported in the Git Console. Please find some of the commonly used Git commands listed below.*

<pre><code>1. git init: #Initializes a new Git repository in the current directory
2. git status: #Displays the status of changes as untracked, modified, or staged.
3. git log: #Displays a commit history with commit IDs, authors, dates, and messages.
<strong>4. git log --stat: #Displays commit logs with the list of modified files and the number of lines that have been added or removed in each file.
</strong>5. git config --list: #Displays the Git configuration settings.
6. git add file1 file2 directory/: #Stage specific files or directories for the next commit.
7. git add --all: #Stages all changes, including untracked files, for the next commit.
<strong>8. git commit -m “Your commit message”: #Commits the staged changes with a descriptive message.
</strong>9. git push origin branch_name: #Pushes commits from your local branch to the remote repository's branch.
10. git fetch: #Fetches changes from the remote repository, but do not merge them into your local branch.
<strong>11. git remote -v: #Lists remote repositories linked to the local repository.
</strong><strong>12. git merge branch_name: #Merges changes from another branch into your current branch.
</strong>13. git pull origin branch_name: #Fetches changes from the remote repository and merge them into your current branch.
14. git branch: #Lists all local branches.
15. git checkout branch_name: #Switches to an existing branch.
16. git switch branch_name: #Switch to an existing branch.
17. git checkout -b new_branch_name: #Create a new branch and switch to it in one step.
18. git diff: #Show changes between commits, commit and working tree, etc. 
19. git reset HEAD file: #Unstages/Resets changes for a specific file, but keep the changes in your working directory.
20. git reset --soft HEAD^: #Undo the last commit, but keep the changes from that commit staged.
21. git reset --hard HEAD^: #Undo the last commit and discard all changes made in that commit.
22. git rm: #Removes a file from the working directory and stages the removal.
</code></pre>

{% hint style="info" %}
*<mark style="color:green;">Please Note:</mark> Refer 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 nutshell.*&#x20;
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.bdb.ai/data-science-lab-4/repo-sync-project/tabs-for-a-data-science-lab-project/tabs-for-tensorflow-and-pytorch-environment/notebook/git-console.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
