AI Git Commit Messages in VS Code & Visual Studio | Local LLM Tutorial

Published 30/08/2026

Description

Generate better Git commit messages automatically with Git hooks, PowerShell, and AI. Contents: 0:00 - Introduction 0:15 - Description 0:58 - Git Hooking Flow 3:49 - File Setup 7:22 - Prepare Git Changes 7:53 - Testing Powershell 10:32 - Registering Git Hooks 11:39 - Git Commit 13:58 - VS Code 15:43 - Visual Studio 18:54 - Copilot 21:07 - Antropic 22:07 - Conclusion In this video, I show how to use a prepare-commit-msg Git hook to generate meaningful commit messages from your staged Git diff. Instead of repeatedly writing messages such as “update” or “latest,” a local or cloud-based LLM can analyse the changes you staged and create a more useful summary before the commit is completed. The workflow supports local AI through LM Studio and an Ollama-compatible API endpoint, but the same Git-hook approach can also work with GitHub Copilot CLI, Anthropic, OpenAI-compatible APIs, and other AI providers. I demonstrate the complete flow from changing files locally through generating an AI-assisted commit message and finishing the Git commit. What you will learn How AI-generated Git commit messages work What a prepare-commit-msg Git hook does How Git hooks intercept a commit before it is finalised How to call a PowerShell script from a Git hook How to read the staged Git diff with git diff --cached How to send staged changes to a local LLM How to use LM Studio as an Ollama-compatible local AI endpoint How to configure a model, API base URL, token limits, context limits, and timeouts How to combine an AI-generated message with a developer-written message How to avoid blocking a commit if the AI request fails How to configure Git hooks globally or per repository How to verify the configured Git hook path How to test the PowerShell script before enabling the hook How the workflow behaves from the Git command line How Git hooks work from VS Code How Git hooks work from Visual Studio Why Visual Studio handl