How to remove files from GitHub releases via .gitattributesJune 23, 2017
This is a little thing that I learned when I last updated my footnotes plugin for this blog 1. I use Git as version control system and want to minimize the overhead of deploying new versions to wordpress.org which uses SVN. Since the Git repository contains things like tests and documentation that a WordPress installation does not need, it is not as simple as just copying new versions over to the SVN repository. At least without further configuration, but I then discovered a way of actually making it that simple. The way I do it now is by using a file called .gitattributes. As its name suggests, this is a Git specific file with additional information about the repository just like .gitignore. You can use it to tell Git to exclude certain parts of the repository from generated zip archives. And since GitHub releases are just zip archives generated from the repository source, this is exactly what I needed. This is how .gitattributes of my footnotes plugin looks like:
It simply lists files followed by the
export-ignore statement. After this is pushed to the repository, these files should not appear in zip archives anymore. This includes GitHub releases and the archive you get when you click Download on a GitHub repository. I could probably improve this list with some clever glob patterns, but for now it works and simplifies the process of releasing to SVN a lot. Also: at Wordcamp Europe I have heard rumors that an automatic solution for this process is in the works, but this Git feature might be helpful in other cases as well.