I find a lot of answers on how to reference a GitHub issue in a git comment (using the #xxx notation). I'd like to reference a commit in my comment, generating a link to the commit details page?
5 Answers
To reference a commit, simply write its SHA-hash, and it'll automatically get turned into a link.
the commit 3e5c1e60269ae0329094de131227285d4682b665 solved the issue...
Or use its prefix
the commit 3e5c1e6 solved the issue...
See also:
- The Autolinked references and URLs / Commit SHAs section of Writing on GitHub.
11 Comments
https://github.com/PRJ/issues/NUMBER?VERSION?repository@commit_hashAnswer above is missing an example which might not be obvious (it wasn't to me).
Url could be broken down into parts
https://github.com/liufa/Tuplinator/commit/f36e3c5b3aba23a6c9cf7c01e7485028a23c3811
\_____/\________/ \_______________________________________/
| | |
Account name | Hash of revision
Project name
Hash can be found here (you can click it and will get the url from browser).
Hope this saves you some time.
2 Comments
git log, it will show up on the lines with commit <SHA>. And if that doesn't work, it could be you did not do the git push origin master. Also, there is a bug in github, there must be at least one character after the <SHA> or it doesn't get detected. It can just be a newline or a period.If you are trying to reference a commit in another repo than the issue is in, you can prefix the commit short hash with reponame@.
Suppose your commit is in the repo named dev, and the GitLab issue is in the repo named test. You can leave a comment on the issue and reference the commit by dev@e9c11f0a (where e9c11f0a is the first 8 letters of the sha hash of the commit you want to link to) if that makes sense.
1 Comment
username/reponame@hash in order to identify the fork.I don't think anyone answered the question as asked, perhaps it wasn't possible a decade ago.
However now, as per the github documentation a hash is not required. It can be done thusly:
Individual account
Username/Repository#and issue or pull request number
example: for the issue at https://github.com/aUser/user-repo/issues/23
use: aUser/user-repo#26
Organization
Organization_name/Repository#and issue or pull request number
example: for the issue at https://github.com/an-org/theirproject/issues/1000
use: an-org/theirproject#1000
