Best practices for using git to deploy plugins

Hi there,
Following the advice in one of your recent blog posts on the skills that wordpress developers need to read up on (one of them being the use of git to deploy themes/plugins), I decided to move one of my custom built plugins to a GitHub repositry and get my head around how deployment works.

I have added my plugin files, and created a script that handles updates when a new release is isued - this all works fine. My question is this, what is the best practice for me making changes to my plugin on github and then seeing them on my test site before committing the changes and making a new release? Is this even how people do it, or do they make changes to files on their test site and then push the changes to GitHub and then commit and make a new release?

Hope that makes sense, just looking for some advise on the subject.

  • Sajid
    • DEV MAN’s Sidekick

    Hi @sam69,
    Hope you are doing good today :slight_smile:

    I make changes on local host, test them, if they works then commit the changes on GitHub. That's what I do. HoweverI don't have much experience with GitHub so I am not sure exactly.

    I am flagging our senior plugin developer for his invaluable feedback on this matter to share best practices of code deployment.

    He will post back a reply here as soon as possible. Please bear in mind that their response time might be slower than normal support staff so please be patient.

    Take care and have a nice day :slight_smile:
    Cheers, Sajid

  • Ignacio
    • HummingBird

    This is a very long discussion and would need a lot of time to explain.

    First, here's a guide on how to use Git with WordPress projects: You need to sign up in their newsletter to get a 7 days Course Crash :slight_smile:.

    That said, maybe your answer is not completely answered yet. There are two approaches on this:

    1. Use a repository for a complete installation of WordPress, Plugins and Themes. Ignoring wp-config.php and uploads but including the rest of the files, wp-includes, wp-content and wp-admin. Everything. You test on local using a "development" branch. Once everything is tested, like Plugins/Themes/WP updates are working fine, you merge into master and push to your repository. This repository should be the one in your server. Another option for this would be to make use of Git Hooks: so you don't need to have the repository in your own server but when you make changes, these are copied to your server by using a Git Hook. This option is a little bit more hard to set up.

    2. Make use of Git Submodules. If you have a Plugin that you intend to use in other projects you might want to considerate the use of a Git Submodule. So, again, you have you WP installation as a main repository but then you have several Submodules for every Plugin/Theme you have installed. You can work on Plugins/Themes without affecting your main repository. Once the Plugin/Theme has been updated, you just need to update submodules on your main repository.

    I hope it helps you to start at least, as I said, this topic needs a lot of time :slight_smile:


    • Samuel
      • The Incredible Code Injector

      Thanks Guys
      This is very informative - it's very new for me, but I can already see the benefits. I'm going to take the crash course and see what I can learn - I think in the meantime I will follow what Sajid suggests - it's definetly a good first step in order for me to get going with using github for my plugins immediately - but there's also a lot of room for error with this method I think.

      Would be great if WPMU could provide more resources about this kind of stuff - it's obviously a big topic!

      Thanks again,

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.