user3603360
user3603360

Reputation: 133

How to download a file from Bitbucket using commitId through RestAPI?

I have a commit ID. I want to download the file from Bitbucket using commitID through REST API

curl --user [email protected]:password "https://api.bitbucket.org/2.0/repositories/MyCompany/myrepo/src/master/path/to/file.txt"

This looks like it downloads the latest file from the bitbucket. Can we download the source code for the particular commit ?

Upvotes: 0

Views: 1687

Answers (2)

Avinash Gupta
Avinash Gupta

Reputation: 228

To download the files from a particular commit id :

https://bitbucket.org/projectName/repo-name/get/[commitid].zip

Upvotes: 0

Abhishek
Abhishek

Reputation: 1618

To browse the file from a particular commit you have provide the COMMIT_ID in the query parameter like this :

https://<BITBUCKET_URL>/projects/<PROJECT_GROUP>/repos/<REPO_NAME>/browse?at=<COMMIT_ID>

In your case the curl will look something like this :

curl --user [email protected]:password "https://api.bitbucket.org/2.0/repositories/MyCompany/myrepo/src/master/path/to/file.txt?at=commit_hash"

Upvotes: 1

Related Questions