2.2 KiB
title, intro, redirect_from, versions, topics
| title | intro | redirect_from | versions | topics | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Creating a permanent link to a code snippet | You can create a permanent link to a specific line or range of lines of code in a specific version of a file or pull request. |
|
|
|
This type of permanent link will render as a code snippet only in the repository it originated in. In other repositories, the permalink code snippet will render as a URL.
{% tip %}
Tip: To create a permalink for an entire file, see "Getting permanent links to files."
{% endtip %}
{% data reusables.repositories.navigate-to-repo %}
2. Locate the code you'd like to link to:
- To link to code from a file, navigate to the file.
- To link to code from a pull request, navigate to the pull request and click {% octicon "diff" aria-label="The file diff icon" %} Files changed. Then, browse to the file that contains the code you want include in your comment, and click View.
{% data reusables.repositories.choose-line-or-range %}
4. To the left of the line or range of lines, click {% octicon "kebab-horizontal" aria-label="The horizontal kebab octicon" %}. In the drop-down menu, click Copy permalink.
5. Navigate to the conversation where you want to link to the code snippet.
6. Paste your permalink into a comment, and click Comment.

