How to provide a hyperlink to a particular line(s) of code in stash / bitbucket?

Upon prompting, you will be presented with the following question: Here is a description of each available option: stage this hunk for the next commit, do not stage this hunk for the next commit, quit and do not stage this hunk or any remaining hunks, stage this hunk and all subsequent hunks in the file, do not stage this hunk or any later hunks in the file, select a hunk to go to or search for a hunk matching the given regex, leave this hunk undecided and proceed to the next undecided hunk, leave this hunk undecided and proceed to the next hunk, leave this hunk undecided and go back to the previous undecided hunk, leave this hunk undecided and go back to the previous hunk, split the current hunk into smaller hunks, manually edit the current hunk. Additionally, if the file is not yet in the repository, you can perform the necessary actions beforehand.


By utilizing GitHub, we have the ability to employ URLs that are structured in the following manner.

Please take note of the


located at the end, indicating the lines of code from the 20th to the 45th that are highlighted when the page is loaded in the browser.

Is there a way to link to specific lines of code in
stash / bitbucket
? It seems that this convention does not function in the same manner.

Solution 1:

Within BitBucket, it is necessary for a URL to conclude with




Please refer to the following link for the code snippet:

Concerning Stash, which is now renamed BitBucket Server in 2019+, it is expected that Stash 3.8 in 2015 will have the capability to support deep linking with
multiline selection
. This information is documented in issue BSERV-2477.

By utilizing shift+click, developers have the ability to choose a sequence of lines, subsequently incorporating additional lines into the selection via command+click (or control+click). Afterward, they can copy the URL and share their selection with fellow developers.

The OP confirms in the comments:

The generated stash URL follows a specific format, with


at its end.

You can find the relevant code snippet at this link:

As cellepo notes in the comments:

  • It is not possible to do this in a
    pull request
    /code-review page (


  • The action can be performed on a source page, such as the example URL mentioned earlier.

Solution 2:

It seems possible that the url lines ending may vary depending on different
Bitbucket version

The answer provided by VonC is satisfactory. It seemed to have resolved my issue in the past, but it is no longer effective for me. I suspect that the problem may be due to a different version of BitBucket.

If @VonC’s answer does not solve the problem for you, you can attempt an alternative solution by focusing on




The UI rendering of that differs slightly from the linked example by @VonC, as it only displays blue highlighting on the line-number gutter instead of code identifier
yellow highlighting

“Rephrased MSDTHOT”:

The rendering appears to be the same as the one by @VonC for [non-contiguous] multiline selection. In my version of Bitbucket, non-contiguous selection with CMD + click also functions similarly (as shown below – with emphasis on




Solution 3:

In order to configure
highlighting multiple
blocks in BitBucket, it is necessary for the URL to have the ending of

#lines-a:b,c:d, ...


To avoid repetition, consider removing


if it pertains to whitespace within the URL.

Frequently Asked Questions

Posted in Uncategorized