Integration with Git

abstract This section helps you to integrate Sahi Pro with Git using Sahi Editor.

Git Configuration

Click on the Git Configuration link in Sahi Editor to launch the Git Configuration dialog.

Understanding the Git Configuration dialog

Specify the following Git configuration values as applicable:
info Note:
  1. Before saving the Git Configuration in Sahi, ensure that the remote Git repository is initialized.
  2. Values for Remote Path, Authentication Type and Git Directory can be specified only once. Once Git Configuration is saved successfully, these values will not be editable.
  3. Clicking on the Save button clones the remote Git repository at the specified Git Directory path. To avoid merging errors, ensure the following.
    1. A Git repository should not exist already at this Git Directory path. So a directory with name .git should not be present at the Git Directory path. Note that .git directory if present will be hidden.
    2. Files that will get cloned from the remote Git repository should not already exist in the Git Directory.
  4. For the remote Git repository, it is recommended to have the same directory structure as in the <Sahi>/userdata directory.

Authentication Type

HTTPS Authentication

Enter the User Name and Password after selecting HTTPS Authentication from the dropdown.
info Note:
  1. HTTPS Authentication works only with an HTTPS URL. For example, https://github.com/gituser/git_integration.git.
  2. To modify the saved Git configuration, the user must edit the <sahi_root>/userdata/config/git.properties file.

SSH Authentication

Choose SSH Authentication from the Authentication Type dropdown. Specify the file path of the private key file. Also, enter the Passphrase for the private key if applicable.
info Note:
  1. ssh key should be pem format.
    1. Use following command to generate ssh key in PEM format:
      sh-keygen -t ecdsa -b 521 -m PEM -C "your_email@example.com"
      where: "-m PEM" creates public key to an OpenSSL compatible format
    2. Following command can be used to convert existing public key to an OpenSSL compatible PEM format:
      ssh-keygen -f id_rsa -e -m pem
  2. SSH Authentication works only with an SSH URL which starts with git. For example, git@github.com:gituser/git_integration.git.
  3. To modify the saved Git configuration, the user must edit the <sahi_root>/userdata/config/git.properties file.

Netrc Authentication

Choose Netrc Authentication from the Authentication Type dropdown. Netrc Authentication works with both HTTPS and SSH URLs.
info Note: The tokens machine, login and password should be present in _netrc (on Windows) or .netrc (on Linux or Mac) file.

Git Commit

Click on the Git Commit link in Sahi Editor to launch Git Commit. Git Commit link will appear only after successfully saving the Git Configuration.
Git Commit can also be launched from the Navigator of Sahi Editor by right-clicking on a file or directory name. Clicking on the context menu item Git Commit will add the selected file or directory to Staged Changes.

Understanding the Git Commit tab

  1. Project Info: It specifies the Repository name and Branch Name.
  2. Staged Changes: It contains the list of modified files staged for a commit.
  3. Unstaged Changes: It contains the list of modified files.
  4. Commit Message: Message to describe changes in the commit.
  5. Author: This is the name and email of the author who is checking-in commit. It will be auto-filled using the author details saved in the Git Configuration.
  6. Check-in: This button will check-in staged changes with a commit message.
  7. Check-out: This button will check-out the latest changes from the remote repository.

Click on a file to move it to and fro between Staged Changes and Unstaged Changes. Also, right-clicking on a file will show the following context menu.

Compare with HEAD Revision: Compares the current file with HEAD Revision.

Replace with HEAD Revision: Replaces the current file with HEAD Revision.

Add to index: Adds the current file to index (Staged Changes).

Git History

Click on the Git History link in Sahi Editor to launch Git History. Git History link will appear only after successfully saving the Git Configuration.
Git History can also be launched from the Navigator of Sahi Editor by right-clicking on a file or directory name. Clicking on the context menu item Git History will show all commits checked in for the selected file or directory.

Understanding the Git History tab

  1. List of all commits made in the remote repository.
  2. Information of the selected commit like commit id, author, date and message.
  3. Files that were changed by the selected commit.
  4. Line differences that were made in the selected file by the selected commit.
  5. Search box to search for commits using commit id, message, or author details.

Click on a commit to select and display its information. The list of files changed by the selected commit is shown at the right bottom. Select a file from this list to show the changes made in that file. Also, right-clicking on a file from this list will show a context menu shown in the image below. Clicking on Compare with Current Version will compare the commit version of the file with its current version.


If two commits are selected using ctrl + click, then right-clicking on them will show a context menu shown in the image below. Clicking on Compare with Each Other will compare the selected commits.

Git Compare

The Git Compare tab will compare and show the differences between two versions of a file. It can show the following comparisons.


Comparison between local version and Head version of a file
Right-click on a file in the Git Commit tab and select Compare with HEAD Revision. This will open a comparison between the local version and the Head version of the selected file.
Comparison between local version and Current version of a file
In the Git History tab, the list of files changed by the selected commit is shown at the right bottom. Right-click on a file from this list and select Compare with Current Version. This will open comparison between the local version of the file and the version of the file in the selected commit.


Comparison between two commits
In the Git History tab, select two commits using ctrl + click. Right-click on them and select Compare with Each Other. This will open comparison between the two selected commits. This comparison displays all the modified files in a tree structure. Select any file and view the differences.