简体   繁体   English

如何通过RestAPI使用commitId从Bitbucket下载文件?

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

I have a commit ID. 我有一个提交ID。 I want to download the file from Bitbucket using commitID through REST API 我想通过REST API使用commitID从Bitbucket下载文件

curl --user myuser@mydomain.com:password " https://api.bitbucket.org/2.0/repositories/MyCompany/myrepo/src/master/path/to/file.txt " 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. 看起来它是从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 : 要从特定提交浏览文件,您可以在查询参数中提供COMMIT_ID,如下所示:

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 " 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 : 要从特定的提交ID下载文件:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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