Reputation: 421
I have some php code in a git repository. I use that code in multiple vhosts on the same web server, but different vhosts may use different versions of the code.
How can I create copies of the files from a specific tag in the various vhost httpdocs directories, but without having to replicate the .git directory for each one?
I realise I could git clone/git checkout tag for each vhost, and just delete the .git directory, or use git archive and then unpack the files, but I am assuming/hoping there is a 'proper' git way to do this... something like git archive, but where the files are copied directly to the required location.
Upvotes: 1
Views: 1148
Reputation: 1326994
git archive
(like you mention) is the right command to extract a subdirectory for a given tag.
git archive [-o | --output=<file>] <tree-ish> [<path>…]
<tree-ish>
would be your tagBut that means for you to process that archive and uncompress it to the right place, which, as Bombe points out in the comments, can be done with:
git archive --format=tar … | tar -C /path/to/target -xf -
Upvotes: 1