This is part 1 of a series on all things Git, from a rundown of the platform and explanation of benefits to non-technical folks to workflows and tricks for you more technically-inclined fellows. This first part will be an overview of sorts, explaining what the platform is and why you should use it (if you don’t already). Let’s dive right in and answer the $60,000 question:
What in the world is Git?
Well, Morpheus, I’m going to give it the old college try. Git is a source control management system. It’s used to keep track of the files associated with a given project and the changes that occur in those files over time. This can include (but is certainly not limited to) PHP code files, CSS files, and images. Every time you change a file in a project, Git makes note of it. When you’re done making changes to a file or series of files, you commit them to Git, creating a snapshot of them at that moment. That snapshot is saved forever in Git. At any time, you can go back through Git and find any version of any file you’ve ever committed. You can also push your changes out to a central spot where other people working on your project can receive your updates with minimal effort and very low margin for error. You can also create branches so that you can have multiple versions of your project that can be worked on simultaneously.
So what should I use it for?
Well, there’s a few purposes that Git can serve:
1. Keeping your team on the same page.
You can set Git up so that everyone working on a project can connect to the same server and always have the most up-to-date version of the code base. When you update your code base, Git is even smart enough to merge the changes in the up-to-date files with the changes you’ve made, so there’s no need to worry about your changes getting overwritten when you update.
2. Deploying sites.
How many times have you had to do something like this when deploying a site?
Even worse, how many times have you forgot to put a file on that list? Forgetting even one file during a deployment can be a rather costly mistake, potentially making a site look broken or even worse, taking it down entirely. Since Git automatically keeps track of all the files changed in a project, all you need to do to deploy a site is simply update the project from Git and voila! All the files you changed magically show up on your live server. No more forgetting files during deployment.
3. Keeping track of changes to files
How many times have you seen a file that looks like this?
Large chunks of commented-out code that hang around in files are painful to look at. You wouldn’t keep random chunks of your old car in your driveway after buying a new one, would you? You don’t need to worry about losing any code with Git. Once you commit a file, that file is preserved in that state forever. You can always go back through your commits and find any old snippet of code that was ever part of a file, allowing you to get rid of those large comment blocks worry-free!
For further (and nerdier) reading, check out this series on Git basics.
Now that you know what Git is and what it’s used for, I’ll go into how to get started using Git in your every day life! Stay tuned!
Leave a Reply