Sub topic 5
Cross-references and mentions
This chapter assumes you can create issues and pull requests, and that you know what labels and assignees are. It covers the two features that connect issues to each other and to people: cross-references and @mentions. Closing keywords, which build on references, are covered in the next chapter.
Cross-references
A cross-reference is a link from one issue, pull request, or commit to another. GitHub creates it when you type a reference in a description, comment, or commit message. The target item then shows the reference in its timeline, so readers can see where it was mentioned.
Common reference forms:
| You type | What it points to |
|---|---|
| `#42` | Issue or pull request 42 in the same repository |
| `octo-org/api#42` | Issue or pull request 42 in another repository |
| `octo-org/api@a1b2c3d` | A commit in another repository |
| `a1b2c3d` | A commit in this repository (7 or more characters of the SHA) |
| Full issue URL | The same item, shown as a short link |
GitHub turns each of these into a link and often shows the title of the target. Pasting a full URL works the same way as typing the short form.
This looks like the same root cause as #42.
The API side is tracked in octo-org/api#17.
The regression started in commit a1b2c3d.Referencing an item does not change its state. It only adds a note to the target's timeline. This is different from a closing keyword such as Fixes #42, which also closes the issue on merge.
Common reference errors
- A reference inside a code block or inline code is not linked. Writing `
#42` in backticks shows plain text. - A bare number without
#is not a reference. - A reference to a private repository shows no details to people who cannot access it.
- A reference to a repository you misspelled stays plain text, so check that the owner and name are correct.
Mentions
An @mention notifies a person or team. Type @ followed by a username, such as @octocat, in an issue body or comment. GitHub suggests matching names as you type.
@usernamenotifies that user and subscribes them to the thread.@org/team-namenotifies every member of a team in your organization. Members of the team see it in their notifications.- Mentions work in issue descriptions, comments, pull request descriptions, and review comments.
@octocat can you confirm this happens on main?
@octo-org/docs-team the error message needs new wording.Mentions only notify people who have access to the repository. Mentioning someone outside it does not give them access.
Mentions versus assignees
A mention asks for attention on one comment. An assignee owns the work. Use @username for a question or a request for input, and use the assignee field when someone is responsible for finishing the issue.
Notifications caused by mentions are covered later, in the chapter on subscriptions.
Practice
Exercise
In issue 51 of your repository, you want to point to issue 17 in octo-org/api and ask the octo-org/docs-team team to review the wording, without closing anything. What do you write?
Show answer
For example: "Related to octo-org/api#17. @octo-org/docs-team can you review the wording?" The owner/repo#number form links to the issue in the other repository and adds a timeline entry there. The team mention notifies its members. Neither closes anything, because no closing keyword is used.
Exercise
You wrote #42 inside backticks in a comment, but it is not a link. Why, and how do you fix it?
Show answer
GitHub does not parse references inside inline code or code blocks. Remove the backticks so the text is plain, and #42 becomes a link.