Last active
November 16, 2023 03:40
-
-
Save eliranmal/fe796bcd491d333f10742ab8f823c61e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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} | |
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)
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
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}