Skip to content

Instantly share code, notes, and snippets.

Last active November 16, 2023 03:40
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
# a one-liner to get raw content from github enterprise, relying on basic authentication.
# eliminates the need to create an access token and incorporate it in the url.
# fill in the blanks:
# USER your login user name for authentication (you'll be prompted for password on the terminal)
# GHE_DOMAIN the github enterprise custom domain
# REPO_OWNER the user/organization that owns the repository
# REPO_NAME the name of the repository
# REF a git ref, like a branch or commitish (most of the time you'll probably want to use 'master')
# FILE a path for the file to fetch, including file extension. also serves as a name for the file created locally
curl -u "$USER" https://${GHE_DOMAIN}/raw/${REPO_OWNER}/${REPO_NAME}/${REF}/${FILE} > ${FILE}
Copy link

No input, one-liner.
You can get this link by clicking the raw button in the GHE UI, just remove the token query param at the end.

curl -sfSO https://${USER}:${TOKEN}@${GHE_DOMAIN}/raw/${REPO_OWNER}/${REPO_NAME}/${REF}/${FILE}

Copy link

thanx @akhi4u, but the purpose of this snippet is to avoid the inclusion of tokens in the URL (which is less suitable for enterprise workflows)

Copy link

To comment on this further, you can pass the token into the Authorization header instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment