gitcurlgithubbitbucketwget

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?


Solution

  • 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