create_or_update_file
Create a new file or update an existing one in a GitLab project by specifying the file path, content, branch, and commit message.
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. | |
| 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 |