Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I manually add suggestions in code reviews on GitHub?

Tags:

github

In GitHub it's possible to suggest code changes through inline comments in pull requests. But I always get the following error message: "suggestions cannot be applied while viewing a subset of changes".

Is there also a way to manually suggest changes in a comment?

Example: screenshot of problem

like image 399
Stefano Degenkamp Avatar asked Jan 17 '19 15:01

Stefano Degenkamp


2 Answers

Besides the button you can also actually use syntax to make a suggestion. You can do it like:

```suggestion
this is my new suggestion
```
like image 171
Giesburts Avatar answered Oct 19 '22 11:10

Giesburts


How-to code suggest to multiple lines

Apply a code suggestion to multiple lines by highlight dragging the code lines. Starting drag to the right of the line numbers where the comment plus icon appears.

Start dragging

Verify by seeing "Commenting on lines +129 to +145" (or similar) text indicating the multiple line range you are commenting on.

Verify step

Now the code suggestion will replace more than one line!

like image 36
danactive Avatar answered Oct 19 '22 12:10

danactive