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.
If you're the type to live dangerously and don't care about security, use the following:
curl --digest --user <username>:<password> https://bitbucket.org/<username>/<repository>/get/<branchname>.zip -o <branchname>.zip
But if you're like me and care about the security of your applications, let's get down to business
Set up an SSH key 👩🔧 👨🔧
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:
The magic command 🧙♂️🧙♀️
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
Top comments (0)