Learn to effectively comment on GitHub code: sign in, review files, add inline comments or pull request discussions, and manage review feedback.
Book a call with an Expert
Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.
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.
Sign in
.
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.
+
icon appears.+
icon to open the comment field.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.
New pull request
in the repository.Create pull request
.Files changed
tab.+
icon to add an inline review comment.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.
// 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
\*/
# Single-line comment in Python
def add(a, b):
return a + b # inline comment
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.
Conversation
tab to see all review comments.Resolve conversation
on comments you’ve addressed.@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!
When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.