# glab mr create: Open GitLab Merge Requests in CI

> glab mr create opens a GitLab merge request from the command line. Reference for --fill, --source-branch, --target-branch, --yes, and non-interactive CI errors.

Source: https://latchkey.dev/learn/command-reference/glab-mr-create-ci  
Updated: 2026-06-30

glab mr create opens a merge request; --fill and --yes make it fully non-interactive for pipelines.

Automating merge requests (release bumps, dependency updates) needs mr create to run without prompts. The --fill and --yes flags supply the title/description and skip confirmations.

## What it does

glab mr create opens a merge request from the current or a named source branch into a target branch. Without flags it prompts; --fill derives the title and body from commits, and --yes skips the final confirmation.

## Common usage

```Terminal
# fully non-interactive from commit messages
glab mr create --fill --yes \
  --source-branch "$CI_COMMIT_REF_NAME" --target-branch main
# explicit title, label, and auto-merge when pipeline passes
glab mr create --title "Bump deps" --description "automated" \
  --label dependencies --remove-source-branch --yes
```

## Options

| Flag | What it does |
| --- | --- |
| --fill | Derive title and description from commit messages |
| --source-branch <b> | Branch to merge from |
| --target-branch <b> | Branch to merge into (default the repo default branch) |
| --yes / -y | Skip the confirmation prompt |
| --label <name> | Add a label (repeatable) |
| --remove-source-branch | Delete the source branch after merge |
| --draft | Open as a draft merge request |

## In CI

Always pass --fill (or explicit --title/--description) plus --yes; without them glab drops into interactive editors and hangs the job. The token needs api scope; CI_JOB_TOKEN cannot create MRs, so use a project or group access token exported as GITLAB_TOKEN.

## Common errors in CI

"authentication required" means GITLAB_TOKEN is missing or wrong scope. "the request returned error 409: {message: ...} branch ... already has an open merge request" means an MR already exists for that branch. "GraphQL: ... insufficient_scope" or "403 Forbidden" means the token lacks api scope. A silent hang means you omitted --yes and glab is waiting on stdin.

## Using this in CI

CI checkouts are shallow and detached by default, which changes the answer this command gives you. Commands that read history, branch names, or tags need the checkout configured for it.

```.github/workflows/ci.yml
- uses: actions/checkout@v4
  with:
    fetch-depth: 0   # history, tags, and git describe all need this

- run: |
    git rev-parse --is-shallow-repository   # expect false
    git rev-parse --abbrev-ref HEAD          # prints HEAD when detached
```

> `git rev-parse --abbrev-ref HEAD` returns the literal string `HEAD` on a detached checkout rather than a branch name. On GitHub Actions read `github.ref_name` instead; the git command cannot know what it was checked out for.

## FAQ

### glab mr create: Open GitLab Merge Requests in CI?

Automating merge requests (release bumps, dependency updates) needs mr create to run without prompts. The --fill and --yes flags supply the title/description and skip confirmations.

### What it does?

glab mr create opens a merge request from the current or a named source branch into a target branch. Without flags it prompts; --fill derives the title and body from commits, and --yes skips the final confirmation.

### In CI?

Always pass --fill (or explicit --title/--description) plus --yes; without them glab drops into interactive editors and hangs the job. The token needs api scope; CI_JOB_TOKEN cannot create MRs, so use a project or group access token exported as GITLAB_TOKEN.

### Common errors in CI?

"authentication required" means GITLAB_TOKEN is missing or wrong scope. "the request returned error 409: {message: ...} branch ... already has an open merge request" means an MR already exists for that branch. "GraphQL: ... insufficient_scope" or "403 Forbidden" means the token lacks api scope.

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
