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.
Tip: To create a permalink for an entire file, see "Getting permanent links to files."
- En GitHub, visita la página principal del repositorio.
- 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.
- Decide si seleccionar una única línea o un rango:
- Para seleccionar una única línea del código, haz clic en el número de línea para resaltarla.
- Para seleccionar un rango de código, haz clic en el número de la primera línea del rango para resaltar la línea del código. Luego lleva el puntero hasta la última línea del rango del código, presiona Shift y haz clic en el número de línea para resaltar el rango.
- Para seleccionar un rango de código, haz clic en el número de la primera línea del rango para resaltar la línea del código. Luego lleva el puntero hasta la última línea del rango del código, presiona Shift y haz clic en el número de línea para resaltar el rango.
- Para seleccionar una única línea del código, haz clic en el número de línea para resaltarla.
- To the left of the line or range of lines, click . In the drop-down menu, click Copy permalink.
- Navigate to the conversation where you want to link to the code snippet.
- 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, github.com/<organization>/<repository>/blob/<branch_name>/README.md?plain=1
.
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, github.com/<organization>/<repository>/blob/<branch_name>/README.md?plain=1#L14
will highlight line 14 in the plain README.md file.