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."

  1. On GitHub Enterprise, navigate to the main page of the repository.

  2. Navigate to the file or pull request that contains the code you want to link to.

  3. 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.
  4. Hover over the first line of the code range you want and click the line number to highlight the code line. Highlight beginning code line

  5. Hover over the last line of the code range, press Shift, and click the line number to highlight the code range. Highlight ending code line

  6. To the left of the code range, click ... and select Copy permalink. Selecting copy permalink from the drop-down menu

  7. Navigate to the issue or pull request where you want to include the permalink.
  8. Paste your permalink as a comment into the issue or pull request and click Comment. Permalink in same repo renders as code snippet

Further reading