create_or_update_file
Create or update a single file in a GitLab project with a commit, specifying branch, path, content, and commit message. Handles text or base64 encoding for binary files.
Instructions
Create or update a file in a GitLab project. Use this for a single repository file when you know whether the target path is new or already exists; use push_files for a multi-file commit. Optional encoding (text or base64) defaults to GITLAB_REPO_FILE_ENCODING so existing callers stay unchanged. The operation creates or updates remote content in a commit, requires repository write permission, and returns the commit result or a conflict/validation error.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| branch | Yes | Branch to create/update the file in | |
| content | Yes | Content of the file | |
| encoding | No | Content encoding. Use 'base64' for binary files (content must already be base64-encoded). When omitted, GITLAB_REPO_FILE_ENCODING applies. | |
| jmespath | No | Optional JMESPath expression filtering the JSON result before return. | |
| commit_id | No | Current file commit ID (for update operations) | |
| file_path | Yes | Path where to create/update the file | |
| project_id | Yes | Project ID or complete URL-encoded path to project | |
| previous_path | No | Path of the file to move/rename | |
| commit_message | Yes | Commit message | |
| last_commit_id | No | Last known file commit ID |