create_commit
Create a commit on an Azure DevOps Git branch using file changes via search/replace or unified diff formats.
Instructions
Create a commit on an existing branch using file changes.
Provide plain branch names (no "refs/heads/").
⚠️ Each file path may appear only once per commit request—combine all edits to a file into a single change entry.
Prefer multiple commits when you have sparse or unrelated edits; smaller focused commits keep review context clear.
🎯 RECOMMENDED: Use the SEARCH/REPLACE format (much easier, no line counting!).
Option 1: SEARCH/REPLACE format (EASIEST) Simply provide the exact text to find and replace:
{
"changes": [{
"path": "src/api/services/function-call.ts",
"search": "return axios.post(apiUrl, payload, requestConfig);",
"replace": "return axios.post(apiUrl, payload, requestConfig).then(r => { processResponse(r); return r; });"
}]
}The server fetches the file, performs the replacement, and generates the diff automatically. No line counting, no hunk headers, no context lines needed!
Option 2: UNIFIED DIFF format (Advanced) If you prefer full control, provide complete unified diffs:
Each patch MUST have complete hunk headers: @@ -oldStart,oldLines +newStart,newLines @@
CRITICAL: Every @@ marker MUST include line numbers. Do NOT use @@ without line ranges.
Include 3-5 context lines before and after changes.
For deletions:
--- a/filepathand+++ /dev/nullFor additions:
--- /dev/nulland+++ b/filepath
Example unified diff:
{
"changes": [{
"patch": "diff --git a/file.yaml b/file.yaml\n--- a/file.yaml\n+++ b/file.yaml\n@@ -4,7 +4,7 @@ spec:\n spec:\n type: ClusterIP\n ports:\n- - port: 8080\n+ - port: 9090\n targetPort: http\n"
}]
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | No | The ID or name of the project (Default: MyProject) | |
| organizationId | No | The ID or name of the organization (Default: mycompany) | |
| repositoryId | Yes | The ID or name of the repository | |
| branchName | Yes | The branch to commit to (without "refs/heads/", e.g., "codex/test2-delete-main-py") | |
| commitMessage | Yes | Commit message | |
| changes | Yes | List of file changes as either unified git diffs OR search/replace pairs |