How to comment on multiple lines of code in GitHub

Sara Verdi
Sara Verdi
Graphite software engineer

Commenting on multiple lines of code during a code review on GitHub can improve the clarity and effectiveness of feedback. This guide explains the steps and tools necessary to make multi-line comments within GitHub pull requests.

Before you start, you need:

  • A GitHub account.
  • Access to a repository where you can review pull requests.
  1. Open the pull request: Navigate to the GitHub repository and select the pull request where you want to comment.

  2. Start a review: Click on the "Files changed" tab, then find the specific file where you want to comment.

  3. Select multiple lines: Click and drag your mouse over the line numbers on the left side of the code or text diff to highlight multiple lines. You can also hold the Shift key while clicking the starting and ending lines to select a range.

  4. Write your comment: After selecting the lines, a blue comment icon will appear. Click on this icon to open the comment box. Here, you can type your feedback that applies to all selected lines.

  5. Submit review: Once you’ve added comments, scroll to the bottom of the pull request page and click on "Review changes" to submit your review with comments.

Graphite's PR inbox acts like an "email client" for your PRs, allowing you to stay organized and see which pull requests need your attention. It can be particularly helpful when managing large reviews or multiple repositories. Here’s how you can use it in conjunction with GitHub for multi-line comments:

  • Configure your inbox: Set up your default repositories in Graphite to automatically track and organize pull requests.

  • Navigate and review: Use Graphite’s navigation features to quickly find the PRs you need to review, and apply the same multi-line commenting process as in GitHub.

  • Customization and sharing: Customize your inbox sections for different needs, such as “Needs your review” or “Waiting for review.” You can also share these configurations with your team to ensure everyone is aligned.

Commenting on multiple lines in a pull request can provide clearer, more context-specific feedback. This can help prevent misunderstandings and improve the quality of code reviews. Additionally, using tools like Graphite’s PR inbox can enhance this process by organizing your reviews efficiently and aligning team efforts.

Graphite
Git stacked on GitHub

Stacked pull requests are easier to read, easier to write, and easier to manage.
Teams that stack ship better software, faster.

Or install our CLI.
Product Screenshot 1
Product Screenshot 2