You can create a permanent link that refers to a code block in a specific version of a file or pull request. Depending on where you paste the permalink, it will render as a code snippet image or a URL.
Tip: To create a permalink for an entire file, see "Getting permanent links to files."
On GitHub, navigate to the main page of the repository.
Navigate to the file or pull request that contains the code you want to link to.
- Choose one of these options:
- To link to code from another file, click Find file, then search for and open your file. For more information, see "Finding files on GitHub."
- To link to code from a pull request, click Files changed, then browse to the file that contains the code you'd like to include in your issue or pull request, and click View.
Hover over the first line of the code range you want and click the line number to highlight the code line.
Hover over the last line of the code range, press Shift, and click the line number to highlight the code range.
To the left of the code range, click ... and select Copy permalink.
- Navigate to the issue or pull request where you want to include the permalink.
- Paste your permalink as a comment into the issue or pull request and click Comment.