Automating Git Workflow in VS Code: AI Commit & Sync with One Shortcut
Source: Dev.to
Prerequisites
- GitHub Copilot – for AI‑generated commit messages.
- Multi‑command (by ryuta46) – to chain VS Code commands.
Step 1: Define the command sequence
Chain the necessary commands and add a delay so Copilot has time to generate the message.
- Open VS Code Settings (JSON):
Ctrl+Shift+P→ Preferences: Open User Settings (JSON). - Add the following to your settings:
{
"multiCommand.commands": [
{
"command": "multiCommand.aiCommitFlow",
"sequence": [
"git.stageAll",
"github.copilot.git.generateCommitMessage",
{
"command": "extension.multiCommand.execute",
"args": { "interval": 5000 }
},
"git.commitStaged"
]
}
]
}
Note:
interval: 5000(5 seconds) is a safety buffer for the AI. Reduce it to3000if Copilot responds faster.
Step 2: Map the keyboard shortcut
Bind the sequence to a single hotkey.
- Open Keyboard Shortcuts (JSON):
Ctrl+Shift+P→ Preferences: Open Keyboard Shortcuts (JSON). - Add this binding:
{
"key": "ctrl+alt+g",
"command": "multiCommand.aiCommitFlow",
"when": "config.git.enabled"
}
Step 3: Streamline the UI (optional but recommended)
To run the flow without interruption, disable the confirmation dialogs:
- Git: Confirm No Stage Confirmation – uncheck to skip “Do you want to stage all files?”
- Git: Confirm Sync – uncheck to skip the push confirmation.
You can find these settings via Ctrl+, and searching for “Git: Confirm”.
How it works
Press Ctrl + Alt + G and VS Code will:
- Stage all current changes.
- Invoke GitHub Copilot to generate a commit message based on the diff.
- Wait for the configured interval (default 5 seconds) to ensure the message is populated.
- Commit the staged changes.
This transforms a multi‑step manual process into a single, seamless action.