SmartGit AI Feature Tutorials
The following tutorials demonstrate how to use the Generative AI features in SmartGit:
- Getting Started with AI Generated Commenting
- Using the ‘@ai’ placeholder to Reword Commit Messages
- Using the ‘WIP’ placeholder to insert an AI-generated WIP commit message
Tutorial : Getting Started with AI Generated Commenting
SmartGit can use a default configuration to connect to a free LLM (currently, the OpenAI gpt-4.1 model is hosted on the Azure AI Model Inference services), or you can provide your own configuration for any supported LLM provider and model.
For this example, we’ll use the default AI Model.
- In SmartGit, create a new Repository called ‘AISample’ by using Repository | Add or Create from the SmartGit menu and choosing a suitable folder on your local drive. Click Initialize to create the new repository.
- In the folder SmartGit has created, add a file named
AddNumbers.sh
with the following contents:
#!/bin/bash
read -p "Enter first number: " num1
read -p "Enter second number: " num2
sum=$((num1 + num2))
echo "The sum is: $sum"
-
Stage
AddNumbers.sh
for the next commit (you can skip this step if you’re using auto-staging in the Standard Window) -
Instead of typing a commit message, click the
button above the Commit View. As this is your first time using SmartGit’s AI features in this repository, SmartGit will prompt you to select from several AI options. Select Use GitHub models for this repository so that the AI selection is only applied to ‘AISample’. Confirm when prompted.
- Click the AI button again. Within a few seconds, a commit message describing the changes in the new diff will be added to the Commit View.
The generated message should resemble the following:
Add Bash script to read two numbers and output their sum
- You can now accept the AI-generated commit message or tailor it as needed, then commit the changes to your repository.
Tip
Clicking the AI button when a commit message already exists will insert the AI-generated message at the current cursor position.
Tutorial : Using the ‘@ai’ placeholder to Reword Commit Messages
When committing, you can use @ai
as a placeholder to combine user-generated and AI-generated comments.
SmartGit will replace the @ai
placeholder with an AI-generated commit message, similar to the message produced by clicking the AI button.
This is useful when you need to include additional context, non-AI generated information in the commit message, such as a bug tracking ID, that is not related to the code changes.
Continuing from the example above:
- Edit the
AddNumbers.sh
file in your Working Tree folder as follows:
#!/bin/bash
read -p "Enter first number: " number1
read -p "Enter second number: " number2
sum=$((number1 + number2))
echo "The sum is: $sum"
-
Stage the change in SmartGit.
- In the Commit View, add the following commit message:
TUT-1234. AI commit message: @ai
-
Click Commit. SmartGit will detect the
@ai
token and ask if you want to enable@ai
andWIP
placeholder substitution. Click Yes (you’ll only be prompted once). - The commit message (e.g., in the Graph View) should now resemble:
PRO-1234. AI commit message: Rename variable num1 to number1 and variable num2 to number2
Tutorial : Using the ‘WIP’ placeholder to insert an AI-generated WIP commit message
Similar to the @ai
token, SmartGit will replace a commit message which is exactly WIP
or wip
(meaning “Work in Progress”) with an AI generated comment prefixed with WIP:
.
Continuing in our ‘AISample’ repository:
- Add a new file
DivideNumbers.sh
to the ‘AISample’ repository.
#!/bin/bash
#TODO!
-
Stage the new
DivideNumbers.sh
file in SmartGit. -
In the Commit View, enter the following message:
WIP
-
Complete the commit by clicking the Commit button.
The commit message (e.g. in the Graph View) will be updated to reword the WIP
placeholder with an AI-generated message similar to the below.
WIP: Add placeholder script DivideNumbers.sh with TODO comment