开发者

Copying only files from git tag

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开发者_Go百科.


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 tag
  • path would be the right subset of files you need.

But 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 - 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜