GitLabgitlab-org

cli

main
ply7 git calls32 ms100 KiB6 cachedprotocol v2
126 lines7.1 KiBRaw

Create a new merge request.

Synopsis

Defaults to the current branch as the source branch. Use --fill to automatically fill the title and description from the commit history. Use --draft to create a draft merge request.

--attach uploads a file and references it at the end of the description. Repeat the flag for more than one file, or pass - to read the file from standard input. Files upload to the target project, so the references resolve even for a merge request from a fork.

The --attach flag is an experiment. It might be unstable or removed at any time, and is not ready for production use. For more information, see https://docs.gitlab.com/policy/development_stages_support/.

The --recover flag is an experiment: it might be unstable or removed at any time, and is not ready for production use. For more information, see https://docs.gitlab.com/policy/development_stages_support/.

plaintext
glab mr create [flags]

Aliases

plaintext
new

Examples

console
# Create a merge request interactively from the current branch
glab mr new

# Assign a user and set a title without prompting for description
glab mr create -a username -t "fix annoying bug"

# Fill title and description from commits, mark as draft, add a label
glab mr create -f --draft --label RFC

# Fill from commits and preview the compare page in the browser
glab mr create --fill --web

# Fill from commits, expand each commit body into the description
glab mr create --fill --fill-commit-body --yes

# Fill from commits without pushing, for a branch already on the remote
glab mr create --fill --push=false --yes

# Use a merge request template for the description
glab mr create -t "Fix login bug" --template bug_fix
glab mr create -t "Security patch" --template security_fix.md --yes

# Use a template file from outside the repository
glab mr create -t "Fix login bug" --template ~/team-templates/bug_fix.md

# Create against another project without a local clone. All inputs must be passed as flags; no --push, --fill, or --template.
glab mr create --repo group/project --source-branch feature-branch --target-branch main --title "Add feature" --description "Details..." --yes

# Create a fork merge request from your fork into the upstream project, without a local clone.
glab mr create --repo upstream/project --head your-namespace/project --source-branch feature-branch --target-branch main --title "Add feature" --description "Details..." --yes

# Read the description from a file
glab mr create -t "Fix login bug" --description-file description.md

# Read the description from standard input
cat description.md | glab mr create -t "Fix login bug" --description-file -

# Attach a screenshot to the description
glab mr create -t "Fix login bug" -d "Before and after:" --attach ./before.png --attach ./after.png

Options

plaintext
      --allow-collaboration       Allow commits from other members. Set to true/false to override project defaults, or omit to use project settings.
  -a, --assignee usernames        Assign merge request to people by their usernames. Multiple usernames can be comma-separated or specified by repeating the flag.
      --attach stringArray        (EXPERIMENTAL) Upload a file and reference it at the end of the description. Use "-" to read the file from standard input. Repeat the flag to attach multiple files.
      --auto-merge                Set the merge request to merge when all merge checks pass.
      --copy-issue-labels         Copy labels from issue to the merge request. Used with --related-issue.
      --create-source-branch      Create a source branch if it does not exist.
  -d, --description string        Supply a description for the merge request. Set to "-" to open an editor.
      --description-file string   Read the merge request description from a file. Use "-" to read from standard input.
      --draft                     Mark merge request as a draft.
  -f, --fill                      Do not prompt for title or description, and just use commit info. Pushes the branch unless --push=false is set.
      --fill-commit-body          Fill description with each commit body when multiple commits. Can only be used with --fill.
  -H, --head OWNER/REPO           Select another head repository using the OWNER/REPO or `GROUP/NAMESPACE/REPO` format, the project ID, or the full URL.
  -l, --label strings             Add label by name. Multiple labels can be comma-separated or specified by repeating the flag.
  -m, --milestone string          The global ID or title of a milestone to assign.
      --no-editor                 Don't open editor to enter a description. If true, uses prompt. Defaults to false.
      --push                      Push committed changes before creating the merge request. Make sure you have committed changes. Defaults to true with --fill. Use --push=false to skip the push.
      --recover                   Save the options to a file if the merge request creation fails. If the file exists, the options are loaded from the recovery file. (EXPERIMENTAL)
  -i, --related-issue string      Create a merge request for an issue. If --title is not provided, uses the issue title.
      --remove-source-branch      Remove source branch on merge. Set to true/false to override project defaults, or omit to use project settings.
      --reviewer usernames        Request review from users by their usernames. Multiple usernames can be comma-separated or specified by repeating the flag.
      --signoff                   Append a DCO signoff to the merge request description.
  -s, --source-branch string      Create a merge request from this branch. Default is the current branch.
      --squash-before-merge       Squash commits into a single commit when merging. Set to true/false to override project defaults, or omit to use project settings.
  -b, --target-branch string      The target or base branch into which you want your code merged into.
      --template string           Template to pre-populate the description. A name is looked up in '.gitlab/merge_request_templates/' of the local repository, and the '.md' extension is optional. A value that is absolute or contains a path separator is read as a file path, for example '~/templates/feature.md'.
  -t, --title string              Supply a title for the merge request.
  -w, --web                       Continue merge request creation in a browser.
      --wip                       Mark merge request as a draft. Alternative to --draft.
  -y, --yes                       Skip submission confirmation prompt. Use --fill to skip all optional prompts.

Options inherited from parent commands

plaintext
  -h, --help          Show help for this command.
  -R, --repo string   Select another repository. You can use either OWNER/REPO or GROUP/NAMESPACE/REPO. The full URL or Git URL is also accepted.
1---
2title: '`glab mr create`'
3stage: AI Clients
4group: Developer Clients
5info: To determine the technical writer assigned to the Stage/Group associated with this page, see <https://handbook.gitlab.com/handbook/marketing/product-and-technical-marketing/technical-writing/#assignments>
6---
8<!--
9This documentation is auto generated by a script.
10Please do not edit this file directly. Run `make gen-docs` instead.
11-->
13Create a new merge request.
15## Synopsis
17Defaults to the current branch as the source branch. Use `--fill`
18to automatically fill the title and description from the commit history. Use
19`--draft` to create a draft merge request.
21`--attach` uploads a file and references it at the end of the description. Repeat the flag for more than one file, or pass `-` to read the file from standard input. Files upload to the target project, so the references resolve even for a merge request from a fork.
23The `--attach` flag is an experiment. It might be
24unstable or removed at any time, and is not ready for production use.
25For more information, see
26<https://docs.gitlab.com/policy/development_stages_support/>.
28The `--recover` flag is an experiment: it might be unstable or
29removed at any time, and is not ready for production use. For more
30information, see
31<https://docs.gitlab.com/policy/development_stages_support/>.
33```plaintext
34glab mr create [flags]
35```
37## Aliases
39```plaintext
40new
41```
43## Examples
45```console
46# Create a merge request interactively from the current branch
47glab mr new
49# Assign a user and set a title without prompting for description
50glab mr create -a username -t "fix annoying bug"
52# Fill title and description from commits, mark as draft, add a label
53glab mr create -f --draft --label RFC
55# Fill from commits and preview the compare page in the browser
56glab mr create --fill --web
58# Fill from commits, expand each commit body into the description
59glab mr create --fill --fill-commit-body --yes
61# Fill from commits without pushing, for a branch already on the remote
62glab mr create --fill --push=false --yes
64# Use a merge request template for the description
65glab mr create -t "Fix login bug" --template bug_fix
66glab mr create -t "Security patch" --template security_fix.md --yes
68# Use a template file from outside the repository
69glab mr create -t "Fix login bug" --template ~/team-templates/bug_fix.md
71# Create against another project without a local clone. All inputs must be passed as flags; no --push, --fill, or --template.
72glab mr create --repo group/project --source-branch feature-branch --target-branch main --title "Add feature" --description "Details..." --yes
74# Create a fork merge request from your fork into the upstream project, without a local clone.
75glab mr create --repo upstream/project --head your-namespace/project --source-branch feature-branch --target-branch main --title "Add feature" --description "Details..." --yes
77# Read the description from a file
78glab mr create -t "Fix login bug" --description-file description.md
80# Read the description from standard input
81cat description.md | glab mr create -t "Fix login bug" --description-file -
83# Attach a screenshot to the description
84glab mr create -t "Fix login bug" -d "Before and after:" --attach ./before.png --attach ./after.png
85```
87## Options
89```plaintext
90 --allow-collaboration Allow commits from other members. Set to true/false to override project defaults, or omit to use project settings.
91 -a, --assignee usernames Assign merge request to people by their usernames. Multiple usernames can be comma-separated or specified by repeating the flag.
92 --attach stringArray (EXPERIMENTAL) Upload a file and reference it at the end of the description. Use "-" to read the file from standard input. Repeat the flag to attach multiple files.
93 --auto-merge Set the merge request to merge when all merge checks pass.
94 --copy-issue-labels Copy labels from issue to the merge request. Used with --related-issue.
95 --create-source-branch Create a source branch if it does not exist.
96 -d, --description string Supply a description for the merge request. Set to "-" to open an editor.
97 --description-file string Read the merge request description from a file. Use "-" to read from standard input.
98 --draft Mark merge request as a draft.
99 -f, --fill Do not prompt for title or description, and just use commit info. Pushes the branch unless --push=false is set.
100 --fill-commit-body Fill description with each commit body when multiple commits. Can only be used with --fill.
101 -H, --head OWNER/REPO Select another head repository using the OWNER/REPO or `GROUP/NAMESPACE/REPO` format, the project ID, or the full URL.
102 -l, --label strings Add label by name. Multiple labels can be comma-separated or specified by repeating the flag.
103 -m, --milestone string The global ID or title of a milestone to assign.
104 --no-editor Don't open editor to enter a description. If true, uses prompt. Defaults to false.
105 --push Push committed changes before creating the merge request. Make sure you have committed changes. Defaults to true with --fill. Use --push=false to skip the push.
106 --recover Save the options to a file if the merge request creation fails. If the file exists, the options are loaded from the recovery file. (EXPERIMENTAL)
107 -i, --related-issue string Create a merge request for an issue. If --title is not provided, uses the issue title.
108 --remove-source-branch Remove source branch on merge. Set to true/false to override project defaults, or omit to use project settings.
109 --reviewer usernames Request review from users by their usernames. Multiple usernames can be comma-separated or specified by repeating the flag.
110 --signoff Append a DCO signoff to the merge request description.
111 -s, --source-branch string Create a merge request from this branch. Default is the current branch.
112 --squash-before-merge Squash commits into a single commit when merging. Set to true/false to override project defaults, or omit to use project settings.
113 -b, --target-branch string The target or base branch into which you want your code merged into.
114 --template string Template to pre-populate the description. A name is looked up in '.gitlab/merge_request_templates/' of the local repository, and the '.md' extension is optional. A value that is absolute or contains a path separator is read as a file path, for example '~/templates/feature.md'.
115 -t, --title string Supply a title for the merge request.
116 -w, --web Continue merge request creation in a browser.
117 --wip Mark merge request as a draft. Alternative to --draft.
118 -y, --yes Skip submission confirmation prompt. Use --fill to skip all optional prompts.
119```
121## Options inherited from parent commands
123```plaintext
124 -h, --help Show help for this command.
125 -R, --repo string Select another repository. You can use either OWNER/REPO or GROUP/NAMESPACE/REPO. The full URL or Git URL is also accepted.
126```
Diagnostics7 git calls · 32 ms
CallStatusSizeTime032 ms
discover200185 B2 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
git.response.bytes=185
git.server.agent=git/2.56.g1891de4-Linux
git.server.object_format=sha1
git.server.caps=agent ls-refs fetch server-option object-format
git.server.fetch=shallow wait-for-done filter
git.protocol.version=2
git.pkt.frames=9
git.pkt.data=7
git.pkt.flush=2
git.pkt.delim=0
git.pkt.bytes=185
git.pkt.payload.max=35
ls-refs20058 KiB · hit2 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
git.response.bytes=59849
git.response.cache=HIT
git.response.duration_ms=2
git.protocol.version=2
git.pkt.frames=731
git.pkt.data=730
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=59849
git.pkt.payload.max=143
git.ls_refs.count=730
git.ls_refs.head=refs/heads/main
fetchtree:0 · deepen 1020032 KiB · hit2 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=2
git.response.bytes=32926
git.response.cache=HIT
git.response.duration_ms=2
git.fetch.filter=tree:0
git.fetch.wants=0dd7574dce9e385c5c30540e6c15657adc6bdce9
git.fetch.haves.count=0
git.fetch.deepen=10
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=22
git.pkt.data=20
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=32926
git.pkt.payload.max=32046
git.sideband.band1.bytes=32046
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=80
git.pack.bytes=32046
git.pack.ofs_delta=36
git.pack.ref_delta=0
git.pack.chain.max=2
git.pack.trailer=cb0bad5d7ffc514895d8b21c4dd470327f90bc91
git.pack.full=44
Open pack map
fetchcombine:blob:none+tree:2 · deepen 12004.2 KiB · hit4 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=4
git.response.bytes=4273
git.response.cache=HIT
git.response.duration_ms=4
git.fetch.filter=combine:blob:none+tree:2
git.fetch.wants=0dd7574dce9e385c5c30540e6c15657adc6bdce9
git.fetch.haves.count=0
git.fetch.deepen=1
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=7
git.pkt.data=5
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=4273
git.pkt.payload.max=4173
git.sideband.band1.bytes=4173
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=11
git.pack.bytes=4173
git.fetch.wide.objects=11
git.fetch.wide.extra_bytes=3930
git.fetch.wide.blobs=0
fetchtree:02001.7 KiB · hit1 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=1
git.response.bytes=1744
git.response.cache=HIT
git.response.duration_ms=1
git.fetch.filter=tree:0
git.fetch.wants=5e4007a5673eb3bf5d0d7f1a1463c3b2ca3fb3bd
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=4
git.pkt.data=3
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=1744
git.pkt.payload.max=1717
git.sideband.band1.bytes=1717
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=1
git.pack.bytes=1717
git.pack.trailer=3f1b9ccc7756e8941d6705e8187c87fd922113e6
Open pack map
fetchtree:0200669 B · hit2 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=2
git.response.bytes=669
git.response.cache=HIT
git.response.duration_ms=2
git.fetch.filter=tree:0
git.fetch.wants=e7f366ff56d25d838386e3ceead4278af75f7180
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=4
git.pkt.data=3
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=669
git.pkt.payload.max=642
git.sideband.band1.bytes=642
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=1
git.pack.bytes=642
git.pack.trailer=8973f4a733afcd554e109d2cd1877fb7b7210224
Open pack map
fetch2002.5 KiB · hit23 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=23
git.response.bytes=2589
git.response.cache=HIT
git.response.duration_ms=23
git.fetch.wants=9d572195d5e415a337d0ba99c30d96dce13a4263
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=4
git.pkt.data=3
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=2589
git.pkt.payload.max=2562
git.sideband.band1.bytes=2562
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0

Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.

Remote
https://gitlab.com/gitlab-org/cli
Ref
refs/heads/main
Commit
0dd7574dce9e385c5c30540e6c15657adc6bdce9
cf-ray
a5e1301b6867a9fe
Request
0040aa8e…
Protocol
v2 · sha1
Agent
git/2.56.g1891de4-Linux
Filter
advertised
Fetch
shallow wait-for-done filter
Capabilities
agent ls-refs fetch server-option object-format