Biiird Studio

How to package a theme into a zip file using git



While coding a theme or a plugin we often need to copy files into a .zip archive in order to upload it to wordpress. What if one command could do it for us?

Everyone uses git, at least for backup. You can configure git in a way that would upload your files to the server every time you wrote git commit. But it isn’t as straight forward as someone might want. Often we only need to package a .zip archive that would let us upload it in the wordpress admin area.

You can do it with this one simple command:

git archive --format [format] --output [path/to/file] [branch name]

A ready command looks like this:

git archive --format zip --output C:\\Users\\{user_folder_name}\\Desktop\\{theme_or_plugin_name}.zip main

I have put mine in a npm script:

"zip": "git archive --format zip --output C:\\Users\\micha\\Desktop\\ main"

Now the only thing I have to do is write npm run zip in the command line and almost instantly I will have a .zip file with my theme on my desktop, ready to be uploaded. The git archive command respects the .gitignore file, so you can easily choose what files/folders you want in your .zip file.

Mike Kuczek

Mike Kuczek

WordPress developer, designer, psychology student and bluberry farmer. CEO of Biiird Studio.

Improve performance of WP_Query

Using these three arguments as an addition to your’s can speed up the query process. Check the comments to be sure you can use them.

0 komentarzy


Leave a Comment

Your email address will not be published. Required fields are marked *

Zasób 1

Switch to Polish: 

Switch to English: 

Ta strona korzysta z plików cookie, korzystając z niej zgadzasz się na ich wykorzystanie. Więcej informacji.