Notes to self

Create a git branch archive

This week I needed to prepare some files for the buyers of my book Deployment from Scratch. I use various git repositories for the content and case studies, and I needed to create archives for the current release quickly.

Luckily, I found out this is much easier than I made it to.

Instead of manually archiving the files from git ls-files with tar and fiddling with branches, I ended up just calling git archive:

$ git archive $branch -o archive.tar
$ git archive $branch --format=tar.gz -o archive.tar.gz

This is a lifesaver if you have different working branches like I do (alpha for alpha pre-release).

And while I am at it…

If you need an archive of a public project already hosted on GitHub, there is a neat way how to get the gzipped tarball too:

$ wget https://github.com/strzibny/invoice_printer/archive/master.tar.gz
$ wget https://github.com/strzibny/invoice_printer/archive/master.zip
Check out my book
Deployment from Scratch is unique Linux book about web application deployment. Learn how deployment works from the first principles rather than YAML files of a specific tool.
by Josef Strzibny
RSS