Github Commit Syntax to Link a Pull Request/ Issue

34,948

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

Share:
34,948
AlbertEngelB
Author by

AlbertEngelB

Updated on April 06, 2021

Comments

  • AlbertEngelB
    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
    AlbertEngelB about 10 years
    That does indeed work! I tried looking through the documentation and couldn't find anything there, thanks for linking. Example commit with this format.
  • nulltoken
    nulltoken about 10 years
    The 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
    AlbertEngelB about 10 years
    Nice! Thanks for the clarification, it is definitely very useful.
  • bryanbraun
    bryanbraun about 9 years
    This is good for issues, but I don't see anything about linking to a Pull Request.
  • nulltoken
    nulltoken about 9 years
    @bryanbraun This syntax also works for Pull Requests.
  • Rob Stewart
    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
    nulltoken almost 9 years
    @RobStewart the same. You can't have both issue 1 and pull request 1 in a repo.
  • Wildcard
    Wildcard over 6 years
    This answer deserves more attention. I'd never noticed that. Thank you!
  • Tarun Kolla
    Tarun Kolla almost 4 years
    How do I know where this was done if it says "{user} added a commit that referenced this pull request" on PR?
  • Darryl
    Darryl over 3 years
    I wish they spelled this out in github's documentation. I'm sure it's there somewhere, but I haven't seen it.