How to access full source of old commit in BitBucket?
Clash Royale CLAN TAG#URR8PPP
How to access full source of old commit in BitBucket?
Hate to have to ask this on the flow, but for the life of me, 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? So frustrated!
7 Answers
7
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.
.tar.gz
.zip
.zip works too!
– Rakka Rage
Sep 26 '14 at 22:02
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 4:07
I wish they would show this on their website so it was obvious.
– rolls
May 26 '17 at 6:17
No longer relevant for new versions of Bitbucket. Use this answer, stackoverflow.com/a/40268859/6020034
– mdo123
Jun 15 at 15:39
Why 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 bitbucket.org server.
– Rudy Matela
Aug 6 at 16:52
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.
We should point the guys from BitBucket to this answer! :D
– Leniel Maccaferri
Aug 22 '14 at 17:18
This 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 9 '16 at 11:51
https://bitbucket.org/lyro/evil/src/8cbfd51
hg clone https://bitbucket.org/lyro/evil/src/8cbfd51
Found a workaround, it's
hg clone -r8cbfd51 https://bitbucket.org/lyro/evil/src/
– Hi-Angel
Aug 9 '16 at 12:09
hg clone -r8cbfd51 https://bitbucket.org/lyro/evil/src/
For 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
https://bitbucket.org/user/project/commits/0000000000000000000000000000000000000000?at=master
commits
src
Step 1
Step 2
Step 3
Step 4
Final Step
@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 1 '15 at 19:54
LOVE THIS ANSWER. Note: you can also go to the file and use the drop down. THANK YOU!
– mattdlockyer
May 24 '16 at 15:19
More 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 6:17
All 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
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.
This answer is the only one that actually works. The more popular ones seem to refer to older versions of Bitbucket
– Klas Mellbourn
Jun 6 at 10:03
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
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
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.
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.
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).
?until=<sha-of-commit>
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
What new format? Are you using Mercurial or Git? Just use Mercurial or Git clients to update to an old version.
– Erno de Weerd
Jan 25 '13 at 18:49