/github-for-non-tech

How to comment on code in GitHub?

Learn to effectively comment on GitHub code: sign in, review files, add inline comments or pull request discussions, and manage review feedback.

Matt Graham, CEO of Rapid Developers

Book a call with an Expert

Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.

Book a free No-Code consultation

How to comment on code in GitHub?

 

Step 1: Sign in to GitHub and open your repository

 

First, make sure you have a GitHub account and are signed in. Then navigate to the repository where you want to comment on code.

  • Go to https://github.com/ and click Sign in.
  • Select the repository from your dashboard or search bar.

 

Step 2: Commenting directly on a file in the repository view

 

You can leave inline comments on any file in the repository without creating a pull request.

  • In the repository, click on the file you want to comment on.
  • Hover over the line number where you want to add your comment. A blue icon appears.
  • Click the icon to open the comment field.
  • Type your comment and click Comment.

// Example screenshot of line comment in GitHub web UI:
// 1. File view with line numbers
// 2. Click the "+" next to the desired line
// 3. Add your comment in the textbox

 

Step 3: Commenting on code in a Pull Request

 

For a full code review experience, use pull requests to discuss changes before merging.

  • Create a pull request by clicking New pull request in the repository.
  • Select the base and compare branches, then click Create pull request.
  • Go to the Files changed tab.
  • Hover over the line number and click the icon to add an inline review comment.
  • After adding comments on multiple lines, click Review changes and choose Comment, Approve, or Request changes.

# Terminal example: open pull request from a feature branch
git checkout -b feature-comment-demo
# make some changes
git add .
git commit -m "Demo comments"
git push origin feature-comment-demo
# Then open the PR on GitHub and leave inline comments.

 

Step 4: Adding comments within your code files before committing

 

You can also insert comments directly in your source code to explain logic. The syntax depends on the language.

  • For JavaScript and many C-style languages:

// This is a single-line comment in JavaScript
function add(a, b) {
  return a + b; /_ inline comment explaining calculation _/
}

/\*
  This is a multi-line comment
  spanning several lines
\*/
  • For Python:

# Single-line comment in Python
def add(a, b):
    return a + b  # inline comment
  • After adding comments, stage and commit your changes:

git add path/to/file
git commit -m "Add explanatory comments to add() function"
git push origin your-branch

 

Step 5: Managing and resolving code comments

 

When working collaboratively, you’ll often need to track and resolve comments.

  • In a pull request, navigate to the Conversation tab to see all review comments.
  • Click Resolve conversation on comments you’ve addressed.
  • Use @mentions (@username) in comments to notify collaborators.

 

Following these steps will help you leave clear, contextual comments on code in GitHub—either directly in files, during pull request reviews, or within your code before committing. Happy collaborating!

Want to explore opportunities to work with us?

Connect with our team to unlock the full potential of no-code solutions with a no-commitment consultation!

Book a Free Consultation

Client trust and success are our top priorities

When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.

Rapid Dev was an exceptional project management organization and the best development collaborators I've had the pleasure of working with. They do complex work on extremely fast timelines and effectively manage the testing and pre-launch process to deliver the best possible product. I'm extremely impressed with their execution ability.

CPO, Praction - Arkady Sokolov

May 2, 2023

Working with Matt was comparable to having another co-founder on the team, but without the commitment or cost. He has a strategic mindset and willing to change the scope of the project in real time based on the needs of the client. A true strategic thought partner!

Co-Founder, Arc - Donald Muir

Dec 27, 2022

Rapid Dev are 10/10, excellent communicators - the best I've ever encountered in the tech dev space. They always go the extra mile, they genuinely care, they respond quickly, they're flexible, adaptable and their enthusiasm is amazing.

Co-CEO, Grantify - Mat Westergreen-Thorne

Oct 15, 2022

Rapid Dev is an excellent developer for no-code and low-code solutions.
We’ve had great success since launching the platform in November 2023. In a few months, we’ve gained over 1,000 new active users. We’ve also secured several dozen bookings on the platform and seen about 70% new user month-over-month growth since the launch.

Co-Founder, Church Real Estate Marketplace - Emmanuel Brown

May 1, 2024 

Matt’s dedication to executing our vision and his commitment to the project deadline were impressive. 
This was such a specific project, and Matt really delivered. We worked with a really fast turnaround, and he always delivered. The site was a perfect prop for us!

Production Manager, Media Production Company - Samantha Fekete

Sep 23, 2022