What is GIT?
In its simplest terms, GIT is version control software used to backup and version your WordPress website. It is by far the most widely used modern software control system in the world. GIT is scalable, meaning you can use it privately to track code changes on a small website or application that you run by yourself, or you can use it on an enterprise level with many developers working on the same code base at the same time.
One of the main features of GIT is the use of branches. Every GIT project has at least one branch – production. Think of your GIT workflow as a tree. The trunk of the tree is your production brach; it’s the core and it’s stable (at least it should be). You can have any number of branches coming off of the core codebase that you can use to implement new features, test new looks, or essentially do anything you want without affecting the core code.
These branches stay separate from your trunk until you have thoroughly tested and vetted the changes. Once your ready you can merge these changes back into the production branch and push them live to your website with a few simple commands. The really great part about this workflow, is that allows you to try new things and if you decide to go in a different direction, you can just roll back to the production branch and continue along a different path.
GIT takes snapshots of your WordPress site at a moment in time (commit) and stores them as unique versions. It allows developers to test new features while maintaining the integrity of the production branch of the website. The key part about this is that you can continue to maintain, update, or otherwise work on the production branch while new features are being implemented on different branches. It is just a matter of pulling those changes from the production branch into your features and when you’re ready, merging your features into production.
GIT, WordPress, and the Cloud
Now, GIT can be installed locally and never connected to an online repository, but there’s no fun in that and your code will be much more recoverable in the event of a disaster if it’s in the cloud. The first thing you’ll want to do is sign up for a service like Github or Bitbucket. My preference is Bitbucket, but it’s just that – a preference and I’m used to it. You can use whatever service works for you. You’ll be able to push your code changes to Bitbucket and if you’re working on a development team you’ll be able to pull down the latest changes they’ve made and vice versa.
Got another recommendation for a repository hosting service like GitHub or Bitbucket? Leave a comment below!
Your WordPress Environment and GIT
Every WordPress website that you’re working on should have the following environments:
- Local Development: This is on your machine and where the real work happens. You can use anything you want from a custom LAMP stack to Larvel Valet.
- Staging Site: Typically this is provided by your hosting solution, but you could have your own staging area on a separate server or even just a /dev folder on your production site (although that’s not really recommended)
- Production Site: This is pretty self-explanatory right? It’s where the people go 🙂
Your staging site and your production site should each have a branch in your GIT repository. Every change or feature you are implementing should ALWAYS be tested on your staging branch first. We want to catch and fix the bugs before production.
Go check out the resources online about GIT and stay tuned for Part 2 where we get a little more in-depth about setting up your local WordPress environment to be GIT-ready. If you’re really enthusiastic about GIT like I am, checkout out these Cheat Sheets on common GIT commands.