Git Console

Git Console functionality helps the data scientists apply various Git commands to their Notebook scripts inside the Repo Sync projects.

Check out the illustration on using the Git Console option inside the Data Science Lab repo sync projects.

Using Git Console

  • Navigate to the Workspace tab of an activated Repo Sync Project.

  • Select a .ipynb file from the Repo Sync Project.

  • The file content opens.

  • Edit the displayed script.

  • Click the Save icon.

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

  • Open the same script in the Git repository.

  • Click the Edit option and access the script in the editable format.

  • Click the Commit changes option.

  • The Commit changes dialog box opens.

  • Provide a commit message.

  • Choose a checkbox to select how the changes should be committed.

  • Click the Commit changes option.

  • The script in the Git repository will be modified.

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

  • 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.

  • Use git status command to reflect the changes.

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

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

  • 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.

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

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

The git config pull rebase false command is committed.

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

  • 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.

  • Click the Delete icon for the conflicted cells.

  • The Delete Cell window appears.

  • Click the Yes option.

  • A notification message appears to ensure that the conflicted cell is removed from the script.

  • Click the Save icon for the script.

Please Note: The user must resolve all the conflicts in the selected file, before saving it.

  • A notification ensures that the script is saved.

  • The saved script reflects the remote changes.

  • 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.

Please Note: the user can click the Refresh icon to refresh the status of the file.

  • 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.

  • 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.

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.

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.
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.
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.
8. git commit -m “Your commit message”: #Commits the staged changes with a descriptive message.
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.
11. git remote -v: #Lists remote repositories linked to the local repository.
12. git merge branch_name: #Merges changes from another branch into your current branch.
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.

Last updated