91

There is an option to comment on a range of lines in file on github, see How to refer to a specific line or range of lines in github?

But is there similar option to comment on range of lines inside pull request? enter image description here

When I click on line, only single line is highlighted yellow and R### (e.g. R446) is appended to url, clicking another line with shift pressed doesn't do anything. I tried to change url to R446-450 but it didn't do anything. Changing it to #L450-458 also didn't do anything. Also even that single highlighted line doesn't seem to affect anything.

Clicking blue plus that appears on hover creates comment window, but it only commenting on a single line.

Commenting on single line results in this enter image description here

Comment on pull-request page shows only 4 lines above selected/commented line, but I'm interested in showing 7 lines, not 4

llamerr
  • 2,997
  • 4
  • 29
  • 40

5 Answers5

83

Since Oct. 2019, Nat Friedman (CEO of GitHub) declares that feature available
(And, see below, since Feb. 2020, multi-lines comment reference is possible)


Multi-line comments are here!
Click and drag to comment on multiple lines in a pull request diff. ✨

These little quality-of-life improvements are at the heart of what we love doing at GitHub.

Multi-line PR comment selection

Thanks to:


Nick Craver immediately asks:

Follow-up question: are there plans to support suggestions?
It seems to apply to the last line at the moment:

multi-line suggestion?

That would be, according to Nat, "Coming early next year".

Update Feb. 2020: "A new interaction for multi-line pull request comments "

To leave a comment referencing multiple lines, you can either:

  • click on a line number in the diff view, hold Shift, click on a second line number and click the "+" button next to the second line number; or
  • click and hold to the right of a line number, drag and then release the mouse when you’ve reached the desired line.

This was announced by Nat Friedman

Shipping today on GitHub: multi-line suggestions!

multi-lines example

With, again, special thanks to Melanie Gilman, Pat Nakajima, Mike Chlipala, Joel Califa, John Caine, Matt Colyer and , and Kelly Arwine.

GitHub Changelog also references this.


Henry adds an observation

A smaller side effect, but I assume being able to share a multi-line diff in the PR is new too!

Example: babel/babel PR 10511 diff-L261-L263

Share multi line

But that was available since July 2019

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • @YaoLi It is possible that feature is yet to be propagated to the on-premise GitHub product, and is still available only on the public website. – VonC Nov 02 '19 at 00:39
  • So love this enhancement! – Deqing Dec 02 '19 at 23:27
  • 1
    Is there a way to do this on mobile? Chrome on android doesn't seem to have a click and drag. – Eric Sep 12 '20 at 09:20
  • @Eric No that does not seem to be supported. Nor is it available in "GitHub for mobile" (https://github.com/mobile) – VonC Sep 12 '20 at 14:30
26

It isn't possible to comment on multiple lines in a pull request review at GitHub. I hope they will create a new feature where this is possible.

But what you can do, there is a little (time consuming) workaround:

If you go in to the code, in the branch with the changes, you can select multiple lines and then copy a permalink for those lines. When you paste this link into your review comment, it will be shown as a code snippet.

For more, read this: https://help.github.com/articles/creating-a-permanent-link-to-a-code-snippet/

Update Github has released a new feature where this is possible. See VonC's answer :-)

Stefan Bols
  • 365
  • 1
  • 4
  • 8
  • 3
    I'v posted a feature request on this matter on GitHub forums: https://github.community/t5/How-to-use-Git-and-GitHub/Feature-request-Multiline-reviews-in-pull-requests/m-p/9850 – Stefan Bols Jul 11 '18 at 13:55
3

To reference multiple lines click on a line number in the diff view, hold shift, and click on a second line number. The URL of the page will update and can be shared with fellow contributors.

To leave a comment referencing multiple lines click and hold to the right of a line number, drag, and then release the mouse when you’ve reached the desired line.

Rytis Dereskevicius
  • 1,261
  • 14
  • 15
  • On GitHub.com, I see that "hold shift and click on a second line number" produces a URL like `...R22-R33` - useful, thanks. Any info on what version that capability is coming to GitHub Enterprise? – Randall Whitman Nov 15 '19 at 01:27
  • 1
    The `...R##-R##` syntax works to highlight a range of lines, in GitHub Enterprise 2.19.4 – Randall Whitman Jan 02 '20 at 20:29
1

The multiline comment feature is now available on GitHub. Enjoy!

0

Multi-line comments have arrived! Git has introduced new feature today for multiline comment please have look

By click on + icon and then drag to multiple lines

https://twitter.com/github/status/1179101186437324801

Niraj Trivedi
  • 2,370
  • 22
  • 24