Skip to content

Instantly share code, notes, and snippets.

@ghawkgu
Last active December 21, 2015 10:19
Show Gist options
  • Save ghawkgu/6291273 to your computer and use it in GitHub Desktop.
Save ghawkgu/6291273 to your computer and use it in GitHub Desktop.
Retrieve single file from remote repository with git.
git archive --remote {remote repository} {branch name/tree-ish} {file path} | tar -x --strip-components={directory depth}
# Use any of the following commands if the tar command does not support --strip-components
git archive --remote {remote repository} {branch name/tree-ish} {file path} | tar -x --strip-path={directory depth}
(git archive --remote {remote repository} {branch name/tree-ish} {file path} | tar -x -O ) > {file name}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment