In order to download a zipped copy of a private Bitbucket repository from the command line, use the following:
curl --digest --user <username>:<password> https://bitbucket.org/<username>/<repository>/get/<branchname>.zip -o <branchname>.zip
where <username>
and <password>
are the Bitbucket account name and password, <repository>
is the repo name and <branchname>
is the branch. If you'd rather download a specific commit, use the SHA-1 hash of the commit in place of <branchname>.
The --digest
flag is for your security, and is highly recommended. It accomplishes authentication so that your username and password are not sent in the clear. The -o
flag sends the output of the curl command to disk as a file, instead of streaming across your terminal screen.
Note: Bitbucket's authentication scheme isn't compatible with wget.
That is why you must use curl.
For public Bitbucket repositories the command is:
curl https://bitbucket.org/<username>/<repository>/get/<branchname>.zip -o <branchname>.zip
Or alternately, you may use wget
for public repositories since no authentication is required:
wget https://bitbucket.org/<username>/<repository>/get/<branchname>.zip
In addition to .zip
format, you may download repositories in .gz
and .bz2
flavors. Simply replace .zip
in the code above with either .gz
or .bz2
to download the repository in the compressed format of your choice.