Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to get raw files at BitBucket?

GitHub offers direct access to files in public repositories by using a link like https://raw.github.com/user/repository/branch/filename. Using a link like this and CURL or WGET I may get a file in a public repository easily.

I recently moved some repositories I had at GitHub to BitBucket, since BitBucket offers me five private repositories for FREE, and FREE always seemed a lovely word for me. But it happens that I'm missing this feature in my public BitBucket repositories.

Is there a similar feature at BitBucket?

If so, what is the format of the URL to get a file?

like image 280
Ed de Almeida Avatar asked Jul 02 '16 17:07

Ed de Almeida


2 Answers

it is easy to get plain text of any file using curl.

curl --user userName https://FQDN/repo_name/raw/fileName -o fileName

for example: URL for the target page in bitbucket: https://bitbucket.myDomain.com/projects/repos/repo/browse/myFile

will end with the following curl request: curl --user username https://bitbucket.myDomain.com/projects/repos/repo/raw/myFile -o targetFile

like image 145
gilad 1 Avatar answered Oct 14 '22 14:10

gilad 1


Yes. https://bitbucket.org/<account>/<repo-name>/raw/<commit-sha-or-HEAD>/<filename>

For this repo: https://bitbucket.org/pedrorijo91/hello-slick/src

Choose a a file (LICENSE for instance): https://bitbucket.org/pedrorijo91/hello-slick/src/fe7cfe392d8090fececdf481ba3a9270bbe678dd/LICENSE?fileviewer=file-view-default

and now click on the RAW button: https://bitbucket.org/pedrorijo91/hello-slick/raw/fe7cfe392d8090fececdf481ba3a9270bbe678dd/LICENSE

It seems bitbucket always adds a SHA before the file. You can specify the commit or HEAD seems to work also: https://bitbucket.org/pedrorijo91/hello-slick/raw/HEAD/LICENSE

like image 26
pedrorijo91 Avatar answered Oct 14 '22 14:10

pedrorijo91