8

When I'm viewing a page with the source code of a certain file on the "master" or "main" branch, often I want to copy the URL of that file but at its actual commit hash so that it's a permalink.

GitLab makes this super obvious. E.g. https://gitlab.com/gitlab-com/chief-of-staff-team/cos-team/-/blob/master/.gitlab/issue_templates/informal_board_meeting.md shows:

enter image description here

GitHub makes it possible too.

What is the fastest, most convenient way to do the same in Bitbucket?

3 Answers 3

4

Its not quick per se, but it is the quickest I've found :-/

Tested on Bitbucket Server v6.10.1

  1. Navigate in the bitbucket to the file you want to link to e.g. https://bitbucket.acme.com/bitbucket/projects/foo/repos/bar/browse/docker/Dockerfile
  2. In the right hand corner of the page there should be sentence like: 'Ms. Frizzle authored fb67a3f2efc 07 April 2021 03:16 PM' Copy the git sha into your clipboard.
  3. In your browser address bar add '?at=' to the end of the url in 1, then paste in the git sha from 2) and hit return, e.g. https://bitbucket.acme.com/bitbucket/projects/foo/repos/bar/browse/docker/Dockerfile?at=fb67a3f2efc

That should give you a shareable permalink.

1
  • Note that you may have to copy the complete git sha. In my case that worked, while copying the abbreviated git sha in the corner of the page did not work.
    – ebrahim
    Jan 17, 2023 at 4:13
2

On Bitbucket Server v6.10.8 (You find your version on the very bottom of any bitbucket page. Maybe this also works for older versions)

2
  • 2
    Pretty incredible BB doesn't provide such a key feature. Jan 12, 2023 at 11:56
  • This should be the accepted answer!
    – k4rtik
    May 24, 2023 at 22:06
2

If you click on a line number of a (source) file, not only the line number becomes part of the current URL, but the respective commit hash as well.

You can stay with the (maybe) superfluous line number or remove it; or remove it together with the file name to generate a permalink for the directory.

1
  • 1
    On what version does that happen?
    – k4rtik
    May 24, 2023 at 22:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.