I can't figure out or find the documentation on how to access the source of an old commit in the new Bit Bucket format. Is this even possible anymore?
-
1What new format? Are you using Mercurial or Git? Just use Mercurial or Git clients to update to an old version. – Emond Jan 25 '13 at 18:49
13 Answers
I understand you want to download an older version via the BitBucket web interface without using a Mercurial/Git client.
Check this related question. On the comments, someone says that there is no way to do that. Fortunately, that's not entirely true.
By navigating on BitBucket project pages, I found no link to download an arbitrary version. There are links to download specific tags, in the format:
https://bitbucket.org/owner/repository/get/v0.1.2.tar.gz
But by tweaking a bit the url above, changing the tag name by the commit hash, like:
https://bitbucket.org/owner/repository/get/A0B1C2D.tar.gz
You can actually download a specific version.
As mentioned by Rakka Rage in a comment, replacing .tar.gz
by .zip
works too.

- 6,310
- 2
- 32
- 37
-
Can I use the link above in the Android Studio terminal to clone a commit? If so, could you provide the basic terminal code? – tccpg288 Nov 29 '16 at 04:07
-
2
-
1Why is it not relevant? I just tested it again (2018-08-06) and it still works. Maybe its an issue with "in house" BitBucket servers? I tested this on the https://bitbucket.org/ server. – Rudy Matela Aug 06 '18 at 16:52
-
-
1@AlexanderMills, I just tested and it works with just `bitbucket.org` as above. Maybe you mean that the `bitbucket.org` URL will be deprecated for this purpose? Is that it? – Rudy Matela May 28 '19 at 22:33
-
2
I was trying to figure out if it's possible to browse the code of an earlier commit like you can on GitHub and it brought me here. I used the information I found here, and after fiddling around with the urls, I actually found a way to browse code of old commits as well.
When you're browsing your code the URL is something like:
https://bitbucket.org/user/repo/src/
and by adding a commit hash at the end like this:
https://bitbucket.org/user/repo/src/a0328cb
You can browse the code at the point of that commit. I don't understand why there's no dropdown box for choosing a commit directly, the feature is already there. Strange.

- 6,885
- 2
- 31
- 43
-
4This is exactly what I needed. A direct link from Bitbucket's site to this URL is sorely missing. – Johnny Oshika Jul 28 '16 at 14:24
-
Alas, this doesn't work. Or rather work, but partially. E.g. you can browse `https://bitbucket.org/lyro/evil/src/8cbfd51` but if you enter `hg clone https://bitbucket.org/lyro/evil/src/8cbfd51`, you'd get some random revision, perhaps the latest. – Hi-Angel Aug 09 '16 at 11:51
-
Found a workaround, it's `hg clone -r8cbfd51 https://bitbucket.org/lyro/evil/src/` – Hi-Angel Aug 09 '16 at 12:09
-
3For those who don't like to copy+paste: browse to a certain commit, the url will be something like `https://bitbucket.org/user/project/commits/0000000000000000000000000000000000000000?at=master`. Now, just change `commits` in the url to `src` and you are browsing the full source at this commit! – Peter Sep 15 '17 at 14:07

- 5,784
- 10
- 53
- 96
-
2@ManojG Here's one from me. So apparently there is a way to get to the whole tree at a certain commit, albeit in a rather confusing way. – Malcolm Jun 01 '15 at 19:54
-
3LOVE THIS ANSWER. Note: you can also go to the file and use the drop down. THANK YOU! – mattdlockyer May 24 '16 at 15:19
-
4More amazing than this answer is the fact that we can't do it on a button click... some things are really amazing.... – Nuno Gonçalves Jun 27 '16 at 14:49
-
this step did not solved for me, what gave results: the answer from @mattdlockyer, select a file, click on the drop down, select a older commit and then return to the repo base link like the last image from oscar post – user2582318 Aug 27 '16 at 06:17
-
1All this works but when download it, its always the latest commit. Am i doing it wrong or it is that way? – Jay Mehta Mar 11 '17 at 19:25
-
Step 3 is an icon now, and the Download button in step 4 and "final" is hidden behind the "..." now – crusy Jan 13 '23 at 09:08
Just in case anyone is in my boat where none of these answers worked exactly, here's what I did.
Perhaps our in house Bitbucket server is set up a little differently than most, but here's the URL that I'd normally go to just to view the files in the master branch:
https://<BITBUCKET_URL>/projects/<PROJECT_GROUP>/repos/<REPO_NAME>/browse
If I select a different branch than master from the drop down menu, I get this:
https://<BITBUCKET_URL>/projects/<PROJECT_GROUP>/repos/<REPO_NAME>/browse?at=refs%2Fheads%2F<BRANCH_NAME>
So I tried doing this and it worked:
https://<BITBUCKET_URL>/projects/<PROJECT_GROUP>/repos/<REPO_NAME>/browse?at=<COMMIT_ID>
Now I can browse the whole repo as it was at the time of that commit.

- 1,835
- 4
- 19
- 23
-
9This answer is the only one that actually works. The more popular ones seem to refer to older versions of Bitbucket – Klas Mellbourn Jun 06 '18 at 10:03
-
Great answers from a couple of years ago. Now Bitbucket has made it easier.
Tag the Commit you want to download (as mentioned in answer by Rudy Matela).
Then head over to Downloads and click the "Tags" tab and you'll get multiple options for download.

- 251
- 4
- 8
-
1This was easily the simplest way to go. For those who have been unable to get tags issues, click on a specific commit and at the top right you will see view source, the branch, the commit, and tags. Add your tag there, then go to download it. – PGMacDesign Nov 07 '18 at 23:34
For the record, you can also toy around URLs this way :
When browsing the latest source, you have something like :
https://bitbucket.org/my/repo/src/latestcommithash/my.file?at=master
Simply change the commit hash and remove the GET parameter :
https://bitbucket.org/my/repo/src/wantedcommithash/my.file
Got to +1 @Hein A. Grønnestad above : it's all working, really wondering why there's nothing in the GUI to use it.

- 1,899
- 23
- 25
The easiest way is to click on that commit and add a tag to that commit. I have included the tag 'last_commit' with this commit
Than go to downloads in the left corner of the side nav in bit bucket. Click on download in the left side
- Now click on tags in the nav bar and download the zip from the UI. Find your tag and download the zip

- 51
- 4
You can view it on your BitBucket web site
As explained on Atlassian community site, it's enough to go to the Source
page (available from left side menu) and put your commit id in the at=
query parameter of the url. So, for example, the url will end with ?at=bacf2ad3095
.

- 965
- 1
- 8
- 11
Add this to the end of any url: ?at=102beada4f1
(using the relevant commit SHA).
Note: the parameter is 'forgotten' with every new page load, so get ctrl + c and ctrl + v ready.
It's astonishing that BitBucket/Stash has no 'Browse files' button in the UI, like GitHub has:
Sigh.

- 41,291
- 27
- 223
- 311
You can view the source of the file up to a particular commit by appending
?until=<sha-of-commit>
in the URL (after the file name).

- 2,292
- 3
- 29
- 43
I know it's too late, but with API 2.0 you can do
from command line with:
curl https://api.bitbucket.org/2.0/repositories/<user>/<repo>/filehistory/<branch>/<path_file>
or in php with:
$data = json_decode(file_get_contents("https://api.bitbucket.org/2.0/repositories/<user>/<repo>/filehistory/<branch>/<path_file>", true));
then you have the history of your file (from the most recent commit to the oldest one):
{
"pagelen": 50,
"values": [
{
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/<user>/<repo>/src/<hash>/<path_file>"
},
"meta": {
"href": "https://api.bitbucket.org/2.0/repositories/<user>/<repo>/src/<HEAD>/<path_file>?format=meta"
},
"history": {
"href": "https://api.bitbucket.org/2.0/repositories/<user>/<repo>/filehistory/<HEAD>/<path_file>"
}
},
"commit": {
"hash": "<HEAD>",
"type": "commit",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/<user>/<repo>/commit/<HEAD>"
},
"html": {
"href": "https://bitbucket.org/<user>/<repo>/commits/<HEAD>"
}
}
},
"attributes": [],
"path": "<path_file>",
"type": "commit_file",
"size": 31
},
{
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/<user>/<repo>/src/<HEAD~1>/<path_file>"
},
"meta": {
"href": "https://api.bitbucket.org/2.0/repositories/<user>/<repo>/src/<HEAD~1>/<path_file>?format=meta"
},
"history": {
"href": "https://api.bitbucket.org/2.0/repositories/<user>/<repo>/filehistory/<HEAD~1>/<path_file>"
}
},
"commit": {
"hash": "<HEAD~1>",
"type": "commit",
"links": {
"self": {
"href": "https://api.bitbucket.org/2.0/repositories/<user>/<repo>/commit/<HEAD~1>"
},
"html": {
"href": "https://bitbucket.org/<user>/<repo>/commits/<HEAD~1>"
}
}
},
"attributes": [],
"path": "<path_file>",
"type": "commit_file",
"size": 20
}
],
"page": 1
}
where values
> links
> self
provides the file at the moment in the history which you can retrieve it with curl <link>
or file_get_contents(<link>)
.
Eventually, from the command line you can filter with:
curl https://api.bitbucket.org/2.0/repositories/<user>/<repo>/filehistory/<branch>/<path_file>?fields=values.links.self
in php, just make a foreach
loop on the array $data
.
Note: if <path_file>
has a /
you have to convert it in %2F
.
See the doc here: https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/filehistory/%7Bnode%7D/%7Bpath%7D

- 11
- 3
Search it for a long time, and finally, I found how to do it:)
Please check this image which illustrates steps.

- 4,555
- 31
- 31
- 45

- 9
- 3