简体   繁体   中英

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 myuser@mydomain.com: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 ?

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 myuser@mydomain.com:password " https://api.bitbucket.org/2.0/repositories/MyCompany/myrepo/src/master/path/to/file.txt?at=commit_hash "

To download the files from a particular commit id :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM