gitgit-archive

git: Select branch when fetching specific file


It is possible to define a specific branch when fetching a file as follows:

git archive --remote=git@my.git.server:namespace/projectname.git HEAD:path/to/file somefile.sql | tar -x

This will retrive the file from the default project branch.

How is it possible to select a specific branch for the above file retrieval?


Solution

  • After some trial and error, turns out this is the way to go about it, when say someone want to get the above file from develop branch:

    git archive --remote=git@my.git.server:namespace/projectname.git develop:path/to/file somefile.sql | tar -x