Skip to content

Instantly share code, notes, and snippets.

@kevinchampion
Created January 25, 2014 00:34
Show Gist options
  • Save kevinchampion/8609773 to your computer and use it in GitHub Desktop.
Save kevinchampion/8609773 to your computer and use it in GitHub Desktop.
Downloads a file from a private repo on GitHub
#!/bin/bash
USER="$1"
PROJECT="$2"
FILE="$3"
DESTINATION="$4"
TOKEN="$5"
REF="$6"
FILEDATA=$(curl https://api.github.com/repos/${USER}/${PROJECT}/contents/${FILE}?access_token=${TOKEN}&REF=${ref})
URL=$(echo $FILEDATA | jq --raw-output '.git_url')
# echo curl -H '"Accept: application/vnd.github.v3.raw"' $URL?access_token=${TOKEN} -o ${DESTINATION}${FILE}
curl -H "Accept: application/vnd.github.v3.raw" $URL?access_token=${TOKEN} -o ${DESTINATION}${FILE}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment