Skip to main content

코드 조각에 대한 고정 링크 만들기

파일 또는 끌어오기 요청의 특정 버전에서 특정 줄 또는 코드 줄 범위에 대한 영구 링크를 만들 수 있습니다.

Linking to code

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.

Screenshot of an issue comment. A code snippet has a header that lists the file name and line numbers, and a body that lists the code on those lines.

Tip: To create a permalink for an entire file, see "Getting permanent links to files."

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

  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 Files changed. Then, browse to the file that contains the code you want include in your comment, and click View.
  3. Choose whether to select a single line or a range.

    • To select a single line of code, click the line number to highlight the line.
    • To select a range of code, click the number of the first line in the range to highlight the line of code. Then, hover over the last line of the code range, press Shift, and click the line number to highlight the range.
  4. To the left of the line or range of lines, click . In the drop-down menu, click Copy permalink.

    Screenshot of a file, with 8 lines selected. To the left of the first selected line, a button labeled with a kebab icon is outlined in dark orange.

  5. Navigate to the conversation where you want to link to the code snippet.

  6. Paste your permalink into a comment, and click Comment.

Linking to Markdown

You can link to specific lines in Markdown files by loading the Markdown file without Markdown rendering. To load a Markdown file without rendering, you can use the ?plain=1 parameter at the end of the url for the file. For example,<organization>/<repository>/blob/<branch_name>/

You can link to a specific line in the Markdown file the same way you can in code. Append #L with the line number or numbers at the end of the url. For example,<organization>/<repository>/blob/<branch_name>/ will highlight line 14 in the plain file.

Further reading