What opening an issue from code actually does
You spot something wrong while reading a file or reviewing a pull request: a broken condition, a hardcoded value, a line that will fail under real data.
You could open a normal issue from the repository page and try to describe where the problem lives.
Or you could open the issue directly from the line of code itself, so GitHub embeds the exact snippet for you.
Which one should you use?
This guide walks through that decision.
GitHub documents a specific flow for opening an issue from a selected line or range of code, and it comes with real limits that matter before you click.
By the end you will know when the code-anchored flow is the right entry point, when a plain issue fits better, and what the anchored issue does and does not give you.
GitHub lets you open a new issue from a specific line or lines of code in a file or in a pull request.
When you do this, the issue contains a snippet showing the line or range of code you chose.
That snippet is the whole point: whoever reads the issue sees the exact code you are talking about, without hunting for it.
The flow is documented for two starting points.
For code in a file, you navigate to the file itself.
For code in a pull request, you open the pull request, click Files changed, browse to the file that contains the code, and click View.
Only then can you select lines.
Selection works the same in both places.
To select a single line, click its line number.
To select a range, click the number of the first line, then hover over the last line, press Shift, and click its line number.
A menu appears to the left of the selected code range; choose Reference in new issue from it.
GitHub then opens the new-issue form with the snippet already in place, and you write the title and description yourself before submitting.
One limit matters most: you can only open the issue in the same repository where the code is stored.
If the problem belongs in a different repository, this flow will not take you there.
The decision check: is the problem tied to lines a reviewer must see?
Before using the code-anchored flow, ask one question: is the defect tied to a specific line or range that a reviewer needs to see to understand the report?
If yes, the anchored flow is usually the better entry point.


