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
$ wget


I wrote a complete guide on web application deployment. Ruby with Puma, Python with Gunicorn, NGINX, PostgreSQL, Redis, networking, processes, systemd, backups, and all your usual suspects.

More →