What is Git?

In this lesson we take a quick look at what Git is. We dive into how Git can be used to keep track of all your code changes. We also take a look at branches and how they can be useful when you are collaborating on a WordPress project. As an example, we will look at the GitHub repository for the WordPress core project.

Transcript

In this video we're going to talk about what Git is. Git is a version control system, and that basically means that you can take all the changes that you make to your source code and group them into these snapshots, so you can always refer back to them later. You can see when a file was changed, who it was changed by, what was changed, and all this stuff Git can tell you.

So I'm here in GitHub, and I'm looking at the Trending Repositories for the PHP language. So if we scroll down just a bit, we can see that WordPress is actually a Trending Repository, which is pretty cool, even though WordPress development isn't even done on GitHub.

WordPress as trending Git repository on GitHub

So if we look at one of the files here, like index.php, and we look at the history for this file. We can see that the last time someone changed index.php was Nacin in 2013. So it hasn't been changed for more than two years. If we click on this commit message, we can see the commit itself here.

The first part here is the commit message, and it just gives us the brief overview of what was changed: “Always use dirname() or, once available, ABSPATH.”

Commit on GitHub by Nacin

So if we scroll down we can see that 105 files was changed, and if we scroll down here we can see all the changes made. So this is really the power of Git. All this was recorded more than two years ago, and we can still see it, all this information.

Another thing about Git is that it has this concept of branching. So if you're working on a new feature, you can sort of branch out, and then you can work on this feature in isolation without having to commit your changes to the master branch, which is probably what is in production on some server. So you don't want to mess around with that, you just want to go out of one branch and work on it, and as soon as you know it's ready and it's ready for production you merge it into the master branch, or whatever branch you use, as your main branch.

So this is a tool called GitX, and it shows you, it's sort of a GUI for Git, so you can see all commits, and branches, and all the stuff you need. So this is actually all commits made to WordPress during the last, yeah since forever. So this is all the commits to the WordPress repository. They're all recorded here. If we scroll down here, what you see out here is the master branch. If we scroll down just a bit, you can see something happens here. So around here there's a new branch going out, and that's actually the 4.4 branch, and they started working on these 4.4 features like the “About Pag”, and all this stuff. Then here it's ready so they tagged it, the 4.4 tag, that means that they can always refer back to this tag, to get this specific version of this source code. The 4.4 version of WordPress.

gitx

You can see that they still added a few commits after that because some of the bug fixes that they're making on the master branch, they still want to apply those to the older versions of WordPress for as long as they're supported. So you can see that here they branched out, and that marks the end of development on WordPress 4.4.Then over here on the master branch they continued working on what is going to be version 4.5 of WordPress.

I think that shows some of the main concepts of Git. Just so you sort of have an idea of what it is, and what it could be useful for. So I think that's all for this video. I hope it was useful to you and I hope to see you in the next videos.

Thank you.

All Lessons

Level up with WP Pusher

Take the pain out of WordPress development. Manage your code with Git and never again deploy files over FTP.

When I came across WP Pusher, I knew I had found the answer and it's now a vital part of our workflow!

Ashley Hart, Green Chilli
GitHub user, runs his local WordPress agency with WP Pusher

WP Pusher makes deploying changes to our websites quick and easy. We could not manage without it.

Simon Appleby, Bookswarm
Bitbucket user, manages 100+ WordPress sites with WP Pusher