gitlab_get_file_content
Retrieve file content from GitLab repositories to read source code, configuration files, or documentation by specifying the file path and optional branch reference.
Instructions
Get file content from repository Returns: Raw file content as string Use when: Reading source code, configs, documentation Optional: Specify branch/tag/commit (defaults to default branch)
Example:
File: 'src/main.py' → Returns Python code
File: 'package.json' → Returns JSON content
File: 'README.md' → Returns Markdown
Related tools:
gitlab_list_repository_tree: Browse files
gitlab_create_commit: Modify files
gitlab_get_commit_diff: See file changes
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | No | Project identifier (auto-detected if not provided) Type: integer OR string Format: numeric ID or 'namespace/project' Optional: Yes - auto-detects from current git repository Examples: - 12345 (numeric ID) - 'gitlab-org/gitlab' (namespace/project path) - 'my-group/my-subgroup/my-project' (nested groups) Note: If in a git repo with GitLab remote, this can be omitted | |
| file_path | Yes | File path in repository Type: string Format: Relative path from repository root using forward slashes Required: Yes Examples: - 'README.md' (root file) - 'src/main.py' (nested file) - 'docs/api/endpoints.md' (deeply nested) - '.github/workflows/ci.yml' (hidden directory) Note: Always use forward slashes, even on Windows | |
| ref | No | Git reference Type: string Format: branch name, tag name, or commit SHA Optional: Yes - defaults to project's default branch Examples: - 'main' (branch) - 'feature/new-login' (feature branch) - 'v2.0.0' (tag) - 'abc1234' (short commit SHA) - 'e83c5163316f89bfbde7d9ab23ca2e25604af290' (full SHA) Default: Project's default branch (usually 'main' or 'master') |