# Git Console

{% hint style="success" %}
*Check out the illustration on using the Git Console option inside the Data Science Lab repo sync projects.*
{% endhint %}

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fz33KQNYQvBTgQKJBgwTz%2Fuploads%2FHESmI8AJQJkVt2vQOJtQ%2FGit%20console_9.0.mp4?alt=media&token=74d6f906-c1d4-47ce-b156-b275081c0bc4>" %}
***Git Console***
{% endembed %}

## Using Git Console <a href="#using-git-console" id="using-git-console"></a>

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

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

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

<figure><img src="/files/7XAZb9zht10iBrDU9Oht" alt=""><figcaption></figcaption></figure>

* A notification ensures that the script is saved with the recent changes.

<figure><img src="/files/7bwmbZiNhMTmmHL45mDa" alt=""><figcaption></figcaption></figure>

* Open the same script in the Git repository.&#x20;

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

* Click the ***Edit*** option and access the script in the editable format.
* Click the ***Commit changes*** option.

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

* The Commit changes dialog box opens.
* Provide a commit message.&#x20;
* Choose a checkbox to select how the changes should be committed.
* Click the ***Commit changes*** option.

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

* The script in the Git repository will be modified.&#x20;

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

* Navigate to the Workspace tab of the Notebook and click the ***Git Consol*** icon.

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

* The Git Console panel opens where you can put the Git command to be performed on the selected script.
* Use the ***Resize panel*** icon to resize the Git Console panel.

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

* Use git status command to reflect the changes.&#x20;

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

* The next commands that can be used are git add and git commit to acknowledge new changes in the file.

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

* The ***git commit*** command generates the information inside the panel about the new changes.

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

* The ***git push*** command is used to push the new changes to the Git Repository. The ***git push*** command has been rejected since there is a change in the repository version of the same file and the console suggests using the ***git pull*** command.

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

* The ***git pull*** command has been used to pull the distant changes from the repository.

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

* At the end of the git pull command, it is hinted to use git config pull rebase false as a default strategy.

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

The git config pull rebase false command is committed.

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

* The auto merge failed due to the merge conflict in the selected file.

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

* Navigate to the ***Workspace*** tab.
* The file title appears in red to indicate the conflict.
* The cells containing conflicted content are highlighted in the script.

<figure><img src="/files/ZxMAoxiVjwhS8gIuZ7KW" 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/oFkFFcERkaHBQa16ZcKi" 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/K1q7fQaPfwH4Xj3Ye7Ae" alt=""><figcaption></figcaption></figure>

* A notification ensures that the script is saved.
* The saved script reflects the remote changes.

<figure><img src="/files/RAq03HFHn6z5uApTDuUn" 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. For example, the given image shows that for the current file conflicts are resolved, but it is in uncommitted status.

{% hint style="info" %}
*<mark style="color:green;">Please Note:</mark> the user can click the **Refresh** icon to refresh the status of the file.*
{% endhint %}

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

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

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

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

<figure><img src="/files/l8rSfhxPkZ6QifuocRoH" 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 merges 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>


---

# 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-5/tabs-for-a-dsl-project/workspace/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.
