Sub topic 5
Applying and dismissing suggested changes
This chapter assumes you can open a pull request, that you have read Copilot's review comments (see the previous chapter), and that you know how commits and branches work in Git. Here you decide what to do with each comment: apply it, change it, or dismiss it.
What a suggestion looks like
Some Copilot comments only describe a concern. Others include a suggested change, which is a small code edit shown as a diff inside the comment. A suggested change has a green and red diff and a Commit suggestion button.
Copilot's review is posted with the "Comment" status. It never approves or blocks the pull request, so nothing you do with its comments counts as an approval. You are the one who decides what happens to each comment.
A decision flow for each comment
Work through the comments one at a time. For each one, ask whether the problem is real, then whether the proposed fix is right.
Applying a suggestion
You have three ways to apply a suggested change.
- Commit suggestion. This creates a commit on the pull request branch with the edit. Use it when the change is small and clearly correct.
- Add suggestion to batch. This collects several suggestions. Then you choose Commit suggestions once. Batching gives you one commit instead of many, which keeps history readable.
- Edit locally. Make the change in your editor, run your tests, and push. Use this when the suggestion needs surrounding changes.
The commit button needs write access to the pull request branch. If the branch is in a fork, you may not have it, so apply the change locally instead.
Here is a typical case. Copilot flags a query built by string concatenation, as your repository instructions ask it to. The suggested change might look like this.
# Before
cursor.execute("SELECT * FROM users WHERE id = " + user_id)
# After (suggested)
cursor.execute("SELECT * FROM users WHERE id = %s", (user_id,))Before you commit it, check that the placeholder style matches your database driver. Some drivers use ? instead of %s. A suggestion can be correct in spirit and still fail in your environment.
Dismissing a suggestion
Dismiss a comment when the concern is wrong, does not apply, or conflicts with a team decision. Common reasons:
- The code is correct and Copilot misread the context.
- The comment is about style that your linter already enforces.
- The suggestion would break behavior that the diff does not show.
To dismiss, reply with a short reason and choose Resolve conversation. The reason helps the next reader understand that you saw the comment and chose not to act. If the same false alarm keeps appearing, add a line to your custom instructions so Copilot stops raising it (covered in a later chapter).
You can also give feedback with the thumbs up or thumbs down buttons on a comment. This feedback is for GitHub, and it does not change the review on your pull request.
Common errors
| Problem | Cause | What to do |
|---|---|---|
| No **Commit suggestion** button | The comment has no suggested change, or you lack write access | Edit the code locally |
| Suggestion is marked outdated | A later commit changed the same lines | Re-read the comment against the new code; apply by hand if still valid |
| Commit fails after batching | Two suggestions overlap on the same lines | Commit them separately |
| Tests fail after applying | The suggestion changed behavior | Revert the commit and fix manually |
Keep the pull request tidy
When you finish, resolve every conversation, whether you applied or dismissed the comment. Resolved conversations collapse, so human reviewers see only open issues. If you pushed new commits, you can ask Copilot to look again, which the next chapter covers.
Exercise
Copilot suggests a change that fixes a real bug but uses a function that does not exist in your library version. What should you do, and why not just click Commit suggestion?
Show answer
The concern is real, but the suggested change is wrong, so follow the "fix it yourself" path. Committing the suggestion would add a commit that fails to run, since Copilot does not execute code. Write a correct fix locally using a function your library version supports, run the tests, push, and resolve the conversation.
Exercise
You have six suggestions that are all small and correct. How can you apply them with the least noise in the pull request history?
Show answer
Use Add suggestion to batch on each one, then choose Commit suggestions once. This creates a single commit containing all six changes.