Sub topic 11
Respond to Review Feedback
This chapter assumes you have already pushed a feature branch to your fork and opened a pull request (PR). It also assumes you know git add, git commit, and git status. Here you will learn how to act on a maintainer's comments and update the PR without opening a new one.
How a PR updates
A pull request tracks a branch, not a fixed set of commits. When you push new commits to the branch on your fork, GitHub adds them to the open PR automatically. You never need to close the PR or open a second one.
Read the feedback first
Before you change anything, read every comment. Reviews come in three common forms:
- Inline comments are attached to a specific line of the diff.
- A review summary is a general comment, often with a status such as "Changes requested" or "Approved".
- Suggestions are inline comments containing a proposed edit that you can accept with one click.
If a comment is unclear, ask a question in reply. Do not guess. A short question costs less than a rewrite in the wrong direction.
Make the changes
Stay on the same feature branch. Check where you are before you edit:
git status
git switch fix-readme-typoMake the requested edits, then commit them. Keep each commit focused on one piece of feedback when you can. A message such as Address review: use a code block for the install command tells the reviewer what changed.
git add README.md
git commit -m "Address review: use a code block for the install command"
git push origin fix-readme-typoYou do not need --force here. The push adds new commits on top of the existing ones, so it is a normal fast-forward.
Reply and resolve
After you push, reply on each comment. Say what you did, for example "Done in a1b2c3d", or explain why you chose differently. Leave it to the reviewer to mark a conversation resolved if the project prefers that. Follow the project's habit, which you can see in other PRs.
You do not have to agree with every comment. If you disagree, explain your reasoning politely and offer to change it if the maintainer still wants that. Maintainers make the final call about their own project.
Fixup commits and squashing
Some projects ask for a clean history with one commit per PR. There are two common ways to meet that:
| Approach | What you do | Result |
|---|---|---|
| Maintainer squashes on merge | Nothing extra. Keep adding commits. | GitHub combines all commits into one when merging. |
| You rewrite your branch | Run an interactive rebase, then force push. | Your branch holds the commits you chose. |
If you rewrite history, push with --force-with-lease, as shown in the rebase chapter. It refuses to overwrite commits you have not seen.
git rebase -i upstream/main
git push --force-with-lease origin fix-readme-typoCommon mistakes
- Opening a new PR for each round of fixes. Push to the same branch instead.
- Committing on
mainby accident. Your PR follows the feature branch, so the fix would never reach it. Rungit branch --show-currentbefore committing. - Fixing unrelated things. Extra changes make review slower. Open a separate branch and PR for them.
- Replying with only "fixed". Mention the commit or explain what changed.
Exercise
A maintainer requests changes on your open PR. You edit the files on your feature branch and commit. What command makes the PR show your new work, and do you need to open a new PR?
Show answer
Run git push origin <your-branch-name>, for example git push origin fix-readme-typo. No new PR is needed. The open PR follows the branch on your fork, so it updates automatically.
Exercise
You rebased your branch to squash commits after review. Which push command should you use, and why is it safer than --force?
Show answer
Use git push --force-with-lease origin <your-branch-name>. It refuses to push if the remote branch contains commits you have not fetched, so you cannot overwrite someone else's work by accident. Plain --force overwrites without checking.