Sub topic 5
Applying and dismissing suggested changes
This chapter assumes you can already request a Copilot review on a pull request and read its comments, as covered in the previous chapters. You should also be comfortable with branches, commits, and the Files changed tab. Here you will learn what happens when you act on a comment: how to apply a suggested change, how to batch several, how to dismiss one cleanly, and how to avoid the mistakes that come up in practice.
What a suggested change is
Copilot's review comments fall into two groups:
- Comments that only describe a concern. Example: "This query is built by string concatenation and may be open to SQL injection." There is nothing to click except Reply and Resolve.
- Comments that include a suggested change. These show a small diff under the comment text, with removed lines in red and added lines in green. GitHub renders them from a
suggestionblock in the comment, the same mechanism a human reviewer uses.
A suggested change is a proposed replacement for the lines the comment is attached to. It is not applied to your branch until someone with write access chooses to apply it. Copilot cannot merge, approve, or push on its own through this review.
Here is a typical suggestion for a Python function, shown as a diff:
- cursor.execute("SELECT * FROM users WHERE id = " + user_id)
+ cursor.execute("SELECT * FROM users WHERE id = %s", (user_id,))The suggestion replaces the one line the comment is attached to. If the suggestion spans several lines, GitHub replaces that whole range.
The decision for each comment
Treat every comment as a small decision. Applying a suggestion is only one of the possible outcomes.
Decide on validity first and look at the diff second. A well-formatted green diff looks authoritative, but it can still be wrong for your codebase.
Applying a single suggestion
You can apply a suggestion from the Conversation tab or from the Files changed tab. The steps are the same in both places:
- Read the comment and the diff. Check that the replacement does what the comment says.
- Select Commit suggestion.
- In the dialog, edit the commit message if you want one. The default is something like "Update src/db.py".
- Select Commit changes.
GitHub then creates a commit on the pull request branch. The commit is authored by you, not by Copilot, because you are the person who chose to apply it. It will appear in the commit list, and GitHub marks the comment as outdated because the lines it pointed at have changed.
Because this is a real commit on the remote branch, your local clone is now behind. Update it before you make more changes, or your next push will be rejected:
git pull --rebase origin my-feature-branchReplace my-feature-branch with your branch name. If you skip this step and commit locally first, you will have to reconcile diverged histories later.
Batching several suggestions into one commit
Applying ten suggestions one by one creates ten commits and can trigger ten CI runs. Batching avoids that.
- Open the Files changed tab. Batching is only available there.
- On each suggestion you want, select Add suggestion to batch.
- Watch the counter on the button. It reads "Commit suggestions (N)" as you add more.
- Select Commit suggestions, write one commit message, and confirm.
Batching has some limits:
- Suggestions in a batch must not overlap. If two suggestions touch the same lines, apply one first.
- The batch exists only in your browser session. If you reload the page or leave, you may lose it, so commit before you walk away.
- Every suggestion in a batch lands in a single commit. If one turns out to break the build, you revert all of them together, so keep each batch to related changes.
A reasonable habit is to batch the small, mechanical fixes (a missing null check, a renamed variable) and apply anything risky on its own, so you can revert it separately.
When a suggestion cannot be applied
The Commit suggestion button is sometimes missing or disabled. Common causes:
| Situation | Why it happens | What to do |
|---|---|---|
| The pull request is closed or merged | Suggestions apply only to open pull requests | Open a new change by hand |
| The lines changed since the review | The comment is outdated and the diff no longer matches | Re-request a review, or edit by hand |
| You lack write access to the head branch | Applying creates a commit on that branch | Ask the author, or check whether maintainers can edit the fork |
| The suggestion is attached to a deleted line | There is nothing left to replace | Edit by hand |
| A pending review of yours is in progress | You are mid-review as a human reviewer | Submit or discard your pending review first, then try again |
If the button is unavailable, you can always copy the suggested lines from the comment and edit the file yourself. The code is the same. Only the one-click convenience is lost.
Checking a suggestion before you commit it
Copilot works from the diff and some surrounding context. It does not run your tests. Before applying, ask these questions:
- Does it compile and pass the linter? Suggestions sometimes use a helper, import, or API that does not exist in your project.
- Does it change behavior beyond what the comment says? A suggestion that "simplifies" a condition can change which inputs pass.
- Is the indentation right? Replacement lines are inserted verbatim. In whitespace-sensitive languages such as Python or YAML, a one-space error can break the file.
- Does it match your conventions? Your repository instructions may tell Copilot to avoid style comments, but it can still propose code that differs from your house style.
The safest check is to let your CI run. After you commit the suggestion, wait for the checks on the new commit, and revert it if they fail. For anything touching security or data, pull the branch and run the code locally.
Dismissing a comment
There is no "reject" button that sends a signal back to Copilot's review. Dismissing a comment means closing the conversation on the pull request. The usual ways are:
- Resolve conversation. The thread collapses and counts as handled. Anyone can reopen it.
- Reply, then resolve. Add a sentence explaining why the concern does not apply. This is worth the effort whenever a human reviewer might wonder why a comment was ignored.
- Leave it unresolved. This is fine for low-value comments, but it clutters the review. If your repository requires all conversations to be resolved before merging, you will have to resolve it anyway.
A good dismissal reason is specific: "This value is validated in parse_request before it reaches this function, so the extra check is redundant." A poor one is "N/A".
Copilot's review also uses the "Comment" status. It does not request changes or approve, so unresolved Copilot comments do not block a merge by themselves. A branch protection rule that requires conversation resolution is what makes them blocking. Check your repository settings to see which applies to you.
Giving feedback on a comment
Copilot's review comments carry thumbs-up and thumbs-down buttons. Use them when a comment was clearly useful or clearly wrong. This feedback goes to GitHub to help evaluate the feature. Do not expect it to change how Copilot reviews your repository tomorrow. To change that behavior, edit your custom instruction files, which are covered in a later chapter.
Applying by hand
Often the right fix is not the suggested one. Copilot may point at a real problem but propose a poor solution. In that case:
- Edit the code yourself and commit as usual.
- Reply on the comment with a short note, for example "Fixed differently: moved the check into the validator."
- Resolve the conversation.
When you push new commits that change the commented lines, GitHub marks the comment as outdated. You can still read it, and you still need to resolve it if your branch rules require that.
Mixed outcomes and partial acceptance
A common pattern is to accept the idea and adjust the details. Apply the suggestion with Commit suggestion, then make a follow-up commit that tweaks it. This keeps the history honest: the first commit shows what Copilot proposed, and the second shows what you changed. If your team squashes pull requests on merge, this distinction disappears from the final history, so the choice matters only for the review period.
Another pattern is a suggestion that fixes one occurrence of a problem that appears in several places. Copilot may comment on only one instance. After applying it, search the codebase for the same pattern and fix the others in the same pull request.
Common errors
- Applying without reading. The diff view makes this easy. Always read the replacement.
- Forgetting to pull. After a suggestion commit, a local
git pushfails with a "non-fast-forward" error. Rungit pull --rebasefirst. - Resolving without acting. Marking a thread resolved does not change the code. Check that the issue is really fixed or really not an issue.
- Batching overlapping suggestions. GitHub will not let you apply both. Apply one, reload, then look at the other.
- Treating "no comments" as "approved". A review with no findings only means Copilot did not flag anything. It is not an approval.
Putting it together
A practical routine for one review round:
- Read all of Copilot's comments first, without clicking anything.
- Sort them into three piles: apply, fix differently, dismiss.
- In Files changed, batch the safe suggestions and commit them once.
- Make manual fixes in a separate commit and push.
- Reply to and resolve every dismissed thread with a reason.
- Wait for CI, then re-request a review if you changed a lot.
Exercise
Copilot comments on line 42 of your pull request with a suggested change. You apply it with Commit suggestion, then immediately edit another file locally and run git push. The push is rejected. What happened, and what should you have done?
Show answer
Commit suggestion created a new commit on the remote pull request branch, so your local branch is behind the remote and the push is a non-fast-forward. Before making local changes, you should have run git pull --rebase origin <branch> to bring in the suggestion commit. Now run that command, resolve any conflicts, and push again.
Exercise
A comment includes a suggestion that is correct for the code Copilot saw, but you decide the concern is already handled elsewhere in the program. List the steps to dismiss it so that a human reviewer understands your decision.
Show answer
Reply on the comment with the specific reason, for example naming the function that already validates the input. Then select Resolve conversation. Do not apply the suggestion. If your repository requires all conversations to be resolved, this also clears that check.
Exercise
Why might the Add suggestion to batch button not be available on the Conversation tab, and where should you go instead?
Show answer
Batching is offered only on the Files changed tab. Open that tab, add each suggestion to the batch, and then commit them together with Commit suggestions.