update_file
Update an existing file in a GitLab repository with optimistic concurrency control. Uses a dry-run preview by default to prevent unintended changes.
Instructions
Update an existing file in a repository. Supports optimistic concurrency via last_commit_id. dry_run=true by default.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes | Project ID | |
| file_path | Yes | File path in repository | |
| branch | Yes | Branch to commit to | |
| content | Yes | New file content | |
| commit_message | Yes | Commit message | |
| encoding | No | Content encoding. Default: text. | |
| last_commit_id | No | Expected last commit ID on the file. If set and stale, GitLab returns 400 to prevent overwriting concurrent changes. | |
| dry_run | No | Dry run mode (default: true). When true, returns a preview of the action without executing it. Set to false only after user confirmation. |