GitLabgitlab-org

cli

main
ply8 git calls332 ms100 KiB6 cachedprotocol v2
144 lines6.3 KiBRaw

Create a comment or discussion on a merge request. (EXPERIMENTAL)

Synopsis

Add a comment to a merge request. By default, the command creates the comment as a new discussion thread.

Use --resolvable=false to create a non-resolvable note instead. Non-resolvable notes do not block merging when the project requires All threads must be resolved. Use this option for automation or status updates that do not need a human to resolve them.

Use --internal to create an internal note, which only project members can view. A reply to an internal thread is itself internal. When combined with --reply, --internal checks the target thread's visibility and fails if the thread is public. Replying to an internal thread without --internal still produces an internal reply.

Use --reply to add a note to an existing discussion thread instead of starting a new one. The value can be a full discussion ID or a unique prefix of at least 8 characters. Find discussion IDs with glab mr note list. Human-readable output uses eight characters before the ellipsis, for example [discussion: abc12345…]; pass only those characters, for example --reply abc12345. To get a full ID, use the id field of each discussion object: glab mr note list -F json | jq -r '.[].id'.

Use --file to place a diff comment on a specific file in the latest merge request diff version. Combine with --line (new side) or --old-line (old/removed side) to target a specific line. Omit both flags for a file-level comment.

To add the comment to a pending review instead of publishing it immediately, use glab mr note draft create.

The flag rules are:

  • --line and --old-line require --file, and cannot be used together.
  • --file, --reply, and --unique are mutually exclusive.
  • --resolvable=false cannot be combined with --reply or --file (and by extension --line or --old-line).
  • --internal cannot be combined with --file (and by extension --line or --old-line), nor with --resolvable=true unless --reply is also given.
  • --attach and --unique are mutually exclusive, because every upload gets a fresh URL and so an attached comment can never match an existing one.

--attach uploads a file and references it at the end of the comment. Repeat the flag for more than one file, or pass - to read the file from standard input. An attachment is content on its own, so a comment with only --attach does not prompt for a body. When standard input is not a terminal, it is read as the comment body, unless --attach - reads the file from standard input. The command waits until standard input closes, so to post only the attachment from a script, redirect standard input from /dev/null.

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

plaintext
glab mr note create [<id> | <branch>] [flags]

Examples

console
# Add a comment to merge request 123
glab mr note create 123 -m "Looks good to me!"

# Add a comment to the current branch's merge request
glab mr note create -m "LGTM"

# Open editor to compose the message
glab mr note create 123

# Pipe from stdin
echo "LGTM" | glab mr note create 123

# Read the body from a file
glab mr note create 123 < plan.md

# Skip if already posted
glab mr note create 123 -m "LGTM" --unique

# Create a non-resolvable note, for example for bot or CI status updates
glab mr note create 123 -m "Build status: green" --resolvable=false

# Create an internal note, visible only to project members
glab mr note create 123 -m "Rotating the leaked token now." --internal

# Reply to an internal thread, refusing to post if that thread is public
glab mr note create 123 --reply abc12345 --internal -m "Patch is ready."

# Reply to an existing discussion thread
glab mr note create 123 --reply abc12345 -m "I agree!"

# Add a diff comment on line 42 of main.go
glab mr note create 123 --file main.go --line 42 -m "Needs refactoring"

# Add a diff comment on lines 10-15 (multiline range)
glab mr note create 123 --file main.go --line 10:15 -m "Extract this block"

# Add a diff comment on a removed line (old side)
glab mr note create 123 --file main.go --old-line 7 -m "Why was this removed?"

# Add a file-level diff comment (no line specified)
glab mr note create 123 --file main.go -m "General comment on this file"

# Attach a screenshot alongside the message
glab mr note create 123 -m "Renders wrong here." --attach ./screenshot.png

# Attach an image piped from the clipboard
pngpaste - | glab mr note create 123 --attach -

Options

plaintext
      --attach stringArray   (EXPERIMENTAL) Upload a file and reference it at the end of the comment. Use "-" to read the file from standard input. Repeat the flag to attach multiple files.
      --file string          File path for a diff comment, like <path/to/file>. Targets the latest merge request diff version.
      --internal             Create the note as an internal note, visible only to project members.
      --line string          Line in the new version. A single line number, like 42, or a range, like 10:15.
  -m, --message string       Comment or note message.
      --old-line int         Line in the old version, for commenting on a removed line.
      --reply string         Reply to an existing discussion. Accepts a full discussion ID or a unique prefix of at least 8 characters.
      --resolvable           Create the note as a resolvable discussion thread. Set to false to create a non-resolvable note. (default true)
      --unique               Don't create a note if a note with the same body already exists. Reads all merge request comments first.

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 note 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 comment or discussion on a merge request. (EXPERIMENTAL)
15## Synopsis
17Add a comment to a merge request. By default, the command creates the comment
18as a new discussion thread.
20Use `--resolvable=false` to create a non-resolvable note instead.
21Non-resolvable notes do not block merging when the project requires
22**All threads must be resolved**. Use this option for automation or status
23updates that do not need a human to resolve them.
25Use `--internal` to create an internal note, which only project members can view. A reply to an internal thread is itself internal. When combined with `--reply`, `--internal` checks the target thread's visibility and fails if the thread is public. Replying to an internal thread without `--internal` still produces an internal reply.
27Use `--reply` to add a note to an existing discussion thread instead of
28starting a new one. The value can be a full discussion ID or a unique
29prefix of at least 8 characters. Find discussion IDs with
30`glab mr note list`. Human-readable output uses
31eight characters before the ellipsis, for example
32`[discussion: abc12345…]`; pass
33only those characters, for example `--reply abc12345`. To get a
34full ID, use the `id` field of each discussion object:
35`glab mr note list -F json | jq -r '.[].id'`.
37Use `--file` to place a diff comment on a specific file in the latest
38merge request diff version. Combine with `--line` (new side) or
39`--old-line` (old/removed side) to target a specific line. Omit
40both flags for a file-level comment.
42To add the comment to a pending review instead of publishing it immediately, use `glab mr note draft create`.
44The flag rules are:
46- `--line` and `--old-line` require `--file`, and
47cannot be used together.
48- `--file`, `--reply`, and `--unique` are mutually
49exclusive.
50- `--resolvable=false` cannot be combined with `--reply`
51or `--file` (and by extension `--line` or
52`--old-line`).
53- `--internal` cannot be combined with `--file`
54(and by extension `--line` or
55`--old-line`), nor with `--resolvable=true` unless
56`--reply` is also given.
57- `--attach` and `--unique` are mutually exclusive,
58because every upload gets a fresh URL and so an attached comment can
59never match an existing one.
61`--attach` uploads a file and references it at the end of the comment. Repeat the flag for more than one file, or pass `-` to read the file from standard input. An attachment is content on its own, so a comment with only `--attach` does not prompt for a body. When standard input is not a terminal, it is read as the comment body, unless `--attach -` reads the file from standard input. The command waits until standard input closes, so to post only the attachment from a script, redirect standard input from `/dev/null`.
63This feature is an experiment and is not ready for production use.
64It might be unstable or removed at any time.
65For more information, see
66<https://docs.gitlab.com/policy/development_stages_support/>.
68```plaintext
69glab mr note create [<id> | <branch>] [flags]
70```
72## Examples
74```console
75# Add a comment to merge request 123
76glab mr note create 123 -m "Looks good to me!"
78# Add a comment to the current branch's merge request
79glab mr note create -m "LGTM"
81# Open editor to compose the message
82glab mr note create 123
84# Pipe from stdin
85echo "LGTM" | glab mr note create 123
87# Read the body from a file
88glab mr note create 123 < plan.md
90# Skip if already posted
91glab mr note create 123 -m "LGTM" --unique
93# Create a non-resolvable note, for example for bot or CI status updates
94glab mr note create 123 -m "Build status: green" --resolvable=false
96# Create an internal note, visible only to project members
97glab mr note create 123 -m "Rotating the leaked token now." --internal
99# Reply to an internal thread, refusing to post if that thread is public
100glab mr note create 123 --reply abc12345 --internal -m "Patch is ready."
102# Reply to an existing discussion thread
103glab mr note create 123 --reply abc12345 -m "I agree!"
105# Add a diff comment on line 42 of main.go
106glab mr note create 123 --file main.go --line 42 -m "Needs refactoring"
108# Add a diff comment on lines 10-15 (multiline range)
109glab mr note create 123 --file main.go --line 10:15 -m "Extract this block"
111# Add a diff comment on a removed line (old side)
112glab mr note create 123 --file main.go --old-line 7 -m "Why was this removed?"
114# Add a file-level diff comment (no line specified)
115glab mr note create 123 --file main.go -m "General comment on this file"
117# Attach a screenshot alongside the message
118glab mr note create 123 -m "Renders wrong here." --attach ./screenshot.png
120# Attach an image piped from the clipboard
121pngpaste - | glab mr note create 123 --attach -
123```
125## Options
127```plaintext
128 --attach stringArray (EXPERIMENTAL) Upload a file and reference it at the end of the comment. Use "-" to read the file from standard input. Repeat the flag to attach multiple files.
129 --file string File path for a diff comment, like <path/to/file>. Targets the latest merge request diff version.
130 --internal Create the note as an internal note, visible only to project members.
131 --line string Line in the new version. A single line number, like 42, or a range, like 10:15.
132 -m, --message string Comment or note message.
133 --old-line int Line in the old version, for commenting on a removed line.
134 --reply string Reply to an existing discussion. Accepts a full discussion ID or a unique prefix of at least 8 characters.
135 --resolvable Create the note as a resolvable discussion thread. Set to false to create a non-resolvable note. (default true)
136 --unique Don't create a note if a note with the same body already exists. Reads all merge request comments first.
137```
139## Options inherited from parent commands
141```plaintext
142 -h, --help Show help for this command.
143 -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.
144```
Diagnostics8 git calls · 332 ms
CallStatusSizeTime0332 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 · hit3 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=3
git.response.bytes=59849
git.response.cache=HIT
git.response.duration_ms=3
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
fetchcombine:blob:none+tree:2 · deepen 12004.2 KiB · hit2 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=3
git.response.bytes=4273
git.response.cache=HIT
git.response.duration_ms=2
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:0 · deepen 1020032 KiB · hit3 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=3
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
fetchtree:02001.7 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=1744
git.response.cache=HIT
git.response.duration_ms=2
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 · 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=669
git.response.cache=HIT
git.response.duration_ms=4
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
fetchtree:0200320 B · hit3 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=3
git.response.bytes=320
git.response.cache=HIT
git.response.duration_ms=3
git.fetch.filter=tree:0
git.fetch.wants=26e1df371683d775a58e6541e378e4f0c2f3d7d0
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=320
git.pkt.payload.max=293
git.sideband.band1.bytes=293
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=1
git.pack.bytes=293
git.pack.trailer=835632d6a936ff937caaf1aeb117c22834ab3425
Open pack map
fetch2002.5 KiB318 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=318
git.response.bytes=2533
git.response.cache=MISS
git.response.duration_ms=318
git.fetch.wants=70d39178163fbba6db47e96ae43a8e81d4e0b484
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=2533
git.pkt.payload.max=2506
git.sideband.band1.bytes=2506
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
a5e152a76b900acb
Request
e70e1167…
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