Unlimited Plugins, WordPress themes, videos & courses! Unlimited asset downloads! From $16.50/m
Lessons:21Length:2.6 hours

Next lesson playing in 5 seconds


Free Preview: Introduction to Git and GitHub


  • Overview
  • Transcript

In this course we'll learn all about the excellent source control management system Git. We'll also see how we can use the brilliant GitHub as a remote source of our Git repositories and as a way to share code with our fellow developers.

Got ten minutes? Why not dive into Git fundamentals in our Coffee Break Courses:

1. Introduction

1.1 Introduction

Hi, folks. Welcome to Git Essentials. My name is Dan Wellman. I'm a software developer from the UK and I work at Microsoft. In this course, we're going to dive in to the source control management system Git. But first of all, what exactly is a source control management system, and what's so special about Git? As developers we're probably used to working with large collections of files. If these files aren't backed up somewhere safe, there's a high chance that they could be lost in the event of a computer failure or become corrupt. So first of all, it's useful just to have a carbon copy backup of all our work. Secondly, I'm sure we've all been in the situation whereby we have a working website which we are maintaining and for some reason or other, a bug is introduced in an update. If this is a big bug that completely breaks the website and makes it unusable, it's useful to be able to quickly roll back to a known working version. We could use the carbon copy backup for this, of course,. But if we've made several changes since the last backup, we could lose a lot more than the just the bug by rolling back. So its useful to have both a backup and a granular way of being able to roll back only very specific changes. Now let's think about when there are a team of developers working on the same website or application. If there isn't some way for these developers to share the changes they make on their own computers with the rest of the team, they will quickly start to overwrite each other's changes. So source control management systems, or SCMs, give us a robust backup for our files, a way to view a history of every change made to every file in the project, and allow teams of often geographically disparate developers all work on the same code without overwriting each other's changes. So onto the next question. Why Git? Unlike a lot of other popular SCMs out there, Git is distributed, which means basically that everyone who works on the code has the full copy of the repository, including all branches and the full history of the project. This is good because once the repository has been claimed or downloaded onto a developer's computer, most of the operations such as creating branches become very fast. Distribution also removes the need for file logs, so developers can all work on the same files in parallel. Git isn't the only distributed SCM, but it's definitely one of the most popular. And one of the reasons for this is because of how it can be linked with GitHub, which we can use to store our code on and share it easily with other developers. A lot of open source JavaScript frameworks and libraries are stored on GitHub, so to participate in open source software development, the chances are you'll need to use Git. Git is often used from the command line, which means it's great for automation as part of the build or continuous integration system. But it also has a number of easy-to-use GUIs available for most popular platforms, including GitK, which comes with Git itself. In this course, we're going to be using the command line on Windows. Installing, configuring and using Git on Windows is largely the same as using it on other platforms. I haven't come across a command yet that I wasn't able to run from the command line on Windows. So whichever platform you're using, you should be able to follow along with all the examples. Let's move on to the next lesson and get Git installed and ready to play with. Thanks for watching.

1.2 Installing and Configuring Git

Hi, folks. In this lesson, we're going to get Git installed and configured, ready for us to use. How you install this depends, of course, on the platform that you're on. Linux users will typically use a package manager to install Git, while OS X users could use either the Git installer or something like HomeBrew to install it. Equally, Windows users could use the Git installer or it can be installed by other various means. Windows users, such as myself, who need to be spend a lot of time in the console, will probably want to install a console emulator that provides an improved command line experience and a decent level of Git integration. One such tool is Cmder, spelt C-M-D-E-R. Not only does this give us a much improved command line experience on Windows, it also provides some special and very useful Git integration features, and even includes Git itself. So in some ways, this is everything we need on the Windows platform. So let's head on over to the Cmder site and download it. So the site's URL is bliker.github.io/cmder. It doesn't have an installer, but there's a package that we can download. So let's just scroll down near the bottom of the page, and there's this Download full button. We'll click that. And we'll just wait for the package to download. As you can see, it's coming down pretty quickly. And once that's downloaded, we need to open the folder, and we can unpack the archive. So we'll just wait for that to unzip. This will probably take longer than the download. So once that's unzipped, we can just copy the entire folder over to somewhere more useful. I'm just going to drop that in the Program Files folder. And again, we just need to wait for that to copy over. And if we just go into the directory now, we can see that there is a file in here called Cmdr.exe. I'm just going to pin that to my taskbar. That's basically installed. So, as I said, this program actually includes a version of Git, so let's just run the application now. And this is what the console looks like in Cmdr. And if we just run git --version, that will tell us the version number of Git that comes with Cmdr. And as you can see, it's version 1.9.4. However, a security vulnerability was recently discovered in this version of Git. So, what I actually want to upgrade this version. To do that, we'll need the installer. So, if we head on over to the Git website, this is where we can download Git for various different platforms. As you can see, there are installers for Mac OS X, Windows, Solaris, and Linux. I believe the Linux version is actually the source, which we'll need to build ourself. I'm gonna download the Windows version now. So again, we just need to wait for that to download. Once that's downloaded, we can just run the installer. And we can just use all of the defaults. And we'll just wait for that to install. And I'm, don't want to read the release notes, so I'm gonna uncheck that box. And once that's installed, that will actually put a Git folder in our Program Files folder, so I'm just gonna go to that now. And it's actually in the Program Files x86 folder. Here's the Git folder. I'm just gonna go in there now. And what I'm gonna do is just copy all of these items. And now I'm gonna head back to the Cmdr folder, and I'm just going to close Cmdr down now. And if we go into the vendor folder, then we can see that there's a folder in here called msysgit. So I'm just going to go into here, and I'm gonna paste in all of the files that I've just copied from the Git folder. So we just need to wait for these to copy across. And I'm going to replace all of the files. [BLANK_AUDIO] So that's happened now. If we close this down, and we can run Cmdr again. And when we run git --version this time, we should hopefully have a higher version number. So we're now running the more secure Git version 1.9.5. Great. So now we have just a little bit of configuration to get out of the way before we can really get started. So whenever we perform some kind of Git related action, Git is going to want to record who exactly carried out that action. So one thing we should do is tell Git who we are. We should set an email address and a username for Git to use. There are several different levels that we can set configuration on. These are the system level, which applies to all users on a single computer, the global level, which applies the configuration for a particular user on a computer, or there is the local level, which only applies settings to a specific Git repository. So let's set our username and our email address, which we can do at the global level, so that the information can be used in every repository we create. To set configuration, we need to use the config command. So let's just run that now. And we supply the global flag to make the configuration change global. And we're just gonna set the user.name value. And I'm just gonna add my name. You can add your name if you want. And I'm just gonna press Enter now. So we don't get any feedback there, but we should be able to verify that the change has happened if we run this command now. [BLANK_AUDIO] And we can see that the name is set to Dan. It's already got my email address in there, but I'm just gonna show you how to set that. So let's come out of Vim now. And we can set the email address in exactly the same way. [BLANK_AUDIO] Great. So just in case you're wondering where that global config file actually get stored, on different platforms, it's in different places. On Windows, it will be in the user folder. On Mac, it will be in the home directory. And let's just take a look at that file. [BLANK_AUDIO] And if we go into the User folder and into our user folder. So my user folder, as you can see, is called Dan. That's, that's my name on this computer. And if we go all the way down to the bottom, we should see a file here called gitconfig. That's .getconfig. If we just open this up in a text editor, then we see the same file that we just saw in Vim. So I just wanna show you one more really useful thing. If we ever need help with the git command, and we wanna see what options we can pass, or the exact format, or anything else like that, then we can enter the command followed by --help. [BLANK_AUDIO] So let's take a look at the help for the config command, [BLANK_AUDIO] And as you can see, what actually happens is that our default browser is launched, and we get a nice HTML formatted page that shows us all of the different options that we can use with whichever command we passed help to. So in this lesson, we installed Git and did the basic configuration to get it ready for us to use. We saw how to use the Git config command and looked at the different levels that configuration can have. We also saw where these global configuration settings are stored. Thanks for watching.