2

Without cloning the repository, we need to fetch a raw file from a specific branch of the GIT repository. It is not clear from the docs of git archive how can we fetch a specific file from a specific branch.

How can we do this?

1 Answer 1

7

You can use git archive and using the -- to specify a file from the branch.

The command is:

git archive --remote=<repo> <branch> -- <path/to/file> | tar -xO 

This outputs to STDOUT, you can redirect from there...

Sign up to request clarification or add additional context in comments.

1 Comment

Just to add that you can set where the file will live using the --directory flag

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.