Github Commit Syntax to Link a Pull Request/ Issue
Solution 1
Use the documented auto-linking format for issues across repositories.
-
Syntax:
{owner}/{repository}#{issue_number}
-
Example:
mojombo/jekyll#1
When such formatted text is present in a commit message, it's automatically transformed into a clickable link which will redirect one to https://github.com/{owner}/{repository}/issues/{issue_number}
Solution 2
Github share PR/Issue number use the same sequence.
So, one #number either one PR or one Issue.
Just use #number is OK.
Solution 3
Use #1234
in a comment to reference pull request 1234 from the current repo.
Solution 4
For linking to another repository, if you just paste the link to the issue or pull request, say https://github.com/{owner}/{repository}/issues/{issue_number}
, GitHub will render it as
[{owner}/{repository}#{issue_number}](https://github.com/{owner}/{repository}/issues/{issue_number})
For example, https://github.com/jlord/sheetsee.js/issues/26 will render as jlord/sheetsee.js#26.
See https://help.github.com/articles/autolinked-references-and-urls/#issues-and-pull-requests
AlbertEngelB
Updated on April 06, 2021Comments
-
AlbertEngelB about 3 years
I've seen commit messages that refer to a specific issue / pull request. What is the syntax to include a specific repository's issue or pull request?
-
AlbertEngelB about 10 yearsThat does indeed work! I tried looking through the documentation and couldn't find anything there, thanks for linking. Example commit with this format.
-
nulltoken about 10 yearsThe provided syntax works for linking across repositories (ie. a commit in repo B linking to an issue in repo A). When pointing at issues in the same repository, you can use the short syntax
#{issue_number}
-
AlbertEngelB about 10 yearsNice! Thanks for the clarification, it is definitely very useful.
-
bryanbraun about 9 yearsThis is good for issues, but I don't see anything about linking to a Pull Request.
-
nulltoken about 9 years@bryanbraun This syntax also works for Pull Requests.
-
Rob Stewart almost 9 years@nulltoken Precisely what is the syntax for citing (and linking) to a pull request? If
mojombo/jekyll#1
is about issue 1, what is the syntax for pull request 1 ? -
nulltoken almost 9 years@RobStewart the same. You can't have both issue 1 and pull request 1 in a repo.
-
Wildcard over 6 yearsThis answer deserves more attention. I'd never noticed that. Thank you!
-
Tarun Kolla almost 4 yearsHow do I know where this was done if it says "{user} added a commit that referenced this pull request" on PR?
-
Darryl over 3 yearsI wish they spelled this out in github's documentation. I'm sure it's there somewhere, but I haven't seen it.