Skip to content

Repository files

Create a file in a repository.

Flags

  • -p, --project <value> — Project id, or its full path such as group/subgroup/project. (required; env: GITLAB_PROJECT)
  • --dry-run — Print the request that would be sent and exit without sending it.
  • --path <value> — Path the file will have in the repository. (required)
  • --branch <value> — Branch to commit to. (required)
  • --content <value> — File contents.
  • --content-file <value> — Path to a local file holding the contents.
  • --message <value> — Commit message. (required)
  • --start-branch <value> — Branch to create —branch from, if it does not exist.
  • --author-email <value> — Commit author email.
  • --author-name <value> — Commit author name.

Connection

  • -e, --env-file <value> — Path to a .env file holding connection settings.
  • --gitlab-url <value> — Base URL of the GitLab instance. Defaults to https://gitlab.com. (env: GITLAB_URL)
  • --gitlab-token <value> — Personal, project, or group access token. (env: GITLAB_TOKEN)

Global

  • --json — the raw API payload, for scripts and agents.

Commits one new file to a branch. GitLab refuses the request if the file already exists — use file update for that — and refuses it if the branch is protected and the token lacks the role to push to it. Use —dry-run to see exactly what would be sent.

Examples

Terminal window
simply gitlab file create --project group/project --path docs/new.md --branch main --content-file ./new.md --message "docs: add page"
Terminal window
simply gitlab file create --project group/project --path src/config.json --branch feature --content-file ./config.json --message "feat: add config" --dry-run

Replace a file in a repository.

Flags

  • -p, --project <value> — Project id, or its full path such as group/subgroup/project. (required; env: GITLAB_PROJECT)
  • --dry-run — Print the request that would be sent and exit without sending it.
  • --path <value> — Path to the file within the repository. (required)
  • --branch <value> — Branch to commit to. (required)
  • --content <value> — New file contents.
  • --content-file <value> — Path to a local file holding the new contents.
  • --message <value> — Commit message. (required)
  • --start-branch <value> — Branch to create —branch from, if it does not exist.
  • --last-commit-id <value> — Reject the write if the file changed since this commit.
  • --author-email <value> — Commit author email.
  • --author-name <value> — Commit author name.

Connection

  • -e, --env-file <value> — Path to a .env file holding connection settings.
  • --gitlab-url <value> — Base URL of the GitLab instance. Defaults to https://gitlab.com. (env: GITLAB_URL)
  • --gitlab-token <value> — Personal, project, or group access token. (env: GITLAB_TOKEN)

Global

  • --json — the raw API payload, for scripts and agents.

Commits new contents over an existing file. The whole file is replaced; there is no partial edit. Pass —last-commit-id with the value file view reported to have GitLab reject the write if someone else changed the file meanwhile, instead of silently overwriting them.

Examples

Terminal window
simply gitlab file update --project group/project --path README.md --branch main --content-file ./README.md --message "docs: refresh readme"
Terminal window
simply gitlab file update --project group/project --path README.md --branch main --content-file ./README.md --message "docs: refresh" --last-commit-id 9a1b2c3

Print a file from a repository.

Flags

  • -p, --project <value> — Project id, or its full path such as group/subgroup/project. (required; env: GITLAB_PROJECT)
  • --path <value> — Path to the file within the repository. (required)
  • --ref <value> — Branch, tag, or commit SHA to read from. (required)
  • --raw — Print only the file contents, with no metadata header.

Connection

  • -e, --env-file <value> — Path to a .env file holding connection settings.
  • --gitlab-url <value> — Base URL of the GitLab instance. Defaults to https://gitlab.com. (env: GITLAB_URL)
  • --gitlab-token <value> — Personal, project, or group access token. (env: GITLAB_TOKEN)

Global

  • --json — the raw API payload, for scripts and agents.

Reads one file at a ref and writes its decoded contents to stdout, under a short metadata header. Use —raw for the contents alone, or —json for the API payload, whose “content” is base64 exactly as GitLab sends it.

A binary file is not printed: its bytes would emit escape sequences to a terminal and noise to whatever reads this stream. The metadata still is, so you can see what was found.

Examples

Terminal window
simply gitlab file view --project group/project --path src/index.ts --ref main
Terminal window
simply gitlab file view --project group/project --path README.md --ref v1.2.0 --raw