A2oz

How do I add code review comments in GitHub?

Published in GitHub 2 mins read

You can add code review comments in GitHub by following these steps:

  1. Navigate to the pull request: Go to the repository where the pull request is located and click on the "Pull requests" tab. Find the pull request you want to review.
  2. View the code: Click on the "Files changed" tab to see the code changes made in the pull request.
  3. Add a comment: Hover over the line of code where you want to add a comment. A small comment icon will appear. Click on the icon to add a comment.
  4. Write your comment: Type your comment in the text box that appears. You can also use Markdown to format your comment.
  5. Submit your comment: Click on the "Add single comment" button to submit your comment.

Types of comments:

  • Line comments: These comments are attached to specific lines of code and provide feedback on that particular line.
  • File comments: These comments are attached to a specific file and provide general feedback on the entire file.
  • General comments: These comments are not attached to any specific code but provide general feedback on the pull request.

Example:

Let's say you want to comment on a line of code that you think is inefficient. You can hover over the line, click on the comment icon, and type:

"This loop could be optimized by using a more efficient algorithm."

Then click on "Add single comment" to submit your comment.

Tips:

  • Be clear and concise in your comments.
  • Focus on providing constructive feedback.
  • Use the appropriate comment type for your feedback.
  • Use Markdown to format your comments.

By following these steps, you can effectively add code review comments in GitHub and contribute to a better codebase.

Related Articles