I'm writing a script to easily download a code stored in a private repository from the command line.
Many solutions to this was exposing credentials in the command line, personally, I didn't want to put my password into my script to accomplish this.
curl --digest --user <username>:<password> https://bitbucket.org/<username>/<repository>/get/<branchname>.zip -o <branchname>.zip
The first step is create private and public keys, I won't go into the details of how to do this, as we have the tutorials on github and bitbucket extramement explicit and clear on how to do this in the best way:
I'll assume that you already have your keys configured, so just run the command below:
git archive --remote=ssh://git@bitbucket_or_github.org/your_username/your_repository.git --format=zip --output="zip_file.zip" desired_branch
Make better choices about your code and your career.