1.Introduction3 lessons, 19:10
2.Basic Commands4 lessons, 23:13
3.A Bit of Theory2 lessons, 23:37
4.Logs and Branches4 lessons, 33:30
5.Github and Remotes4 lessons, 41:49
6.Intermediate Usage6 lessons, 41:55
7.Conclusion1 lesson, 01:07
1.1 Introduction to Git Essentials
Welcome to GIT Essentials. In this course, I'll be teaching you all about GIT, the version control system and source code management tool. Right from the beginning, GIT changed the way I write code for the better, and I think it can do the same for you. But before we actually start learning GIT, I wanna answer a couple of the questions you probably have. There's actually no specific programming knowledge required to use GIT. Of course, GIT is a source code manager, so if you're not writing code, then GIT really won't be useful to you. You're not going to have to write any code for this course, however, GIT is a command line application, this means that you have to be very comfortable on the terminal. Commands like cd, mkdir, ls, mv, rm, and other commands should be very, very familiar to you. If you're not familiar with the terminal, you really should check out Jessie Shawl's How to be a Terminal Pro course, here on Tuts+ Premium. A version control system, or source code manager, is just one of many tools you use when building a website. It's just like your text editor. It's not a library or a framework. The purpose of a source code manager is to track the history of your source code. Mainly, you'll do this by taking snapshots of the source code at different times. Then, if things go bad later on, you can roll back to one of these snapshots. You can also do things like create a branch and work on an experimental feature on another branch, while keeping your production code safe and stable on the main branch. Of course you'll be able to bring these changes in later on, so that they can become a feature on the production branch. Then there are features that allow you to interact with copies of the same code or same project on other computers. This allows you and other developers to develop on the same project on your own and then share your changes back and forth. Right now if you're ready. Let's start by installing GIT on your Windows or Mac computer.
1.2 Getting Started: Installing Git
Let's begin by installing get on our Mac computer, and then we'll look at installing it on our Windows computer. There are a couple of ways to install it on the Mac. My preferred way is to install it via Homebrew. Homebrew builds itself as the missing package manager for OS ten. OS ten is built on the underpinnings of Unix. But, Apple did not include a lot of the standard Unix tools that would come with something like Ubuntu. So Homebrew aims to be a simple package manager, that makes it really easy to install these packages. As you can see right here, once you have Homebrew installed, it's as easy as brew, install, package name. So if you come down here to install Homebrew Today, just click that link, and then all you have to do is copy this line right here. You're gonna open up your terminal, paste that in your terminal and hit Enter. As you can see I get the message here, /user/local/.git already exists. So this just means that I already have Homebrew installed on this computer, so it's not gonna go through the process of installing it again, but if you have not installed Homebrew before, then that will install Homebrew for you. So once you have Homebrew installed, it's as simple as running brew install git. And I'm gonna go ahead and do that, and as you can see, I get an error which tells me git 1.7.10 is already installed. Now, if you don't have Git installed, this is going to install Git for you. However, I'm running into a problem here. And that is if I run git --version, you'll see that even though I have git 1.7.10 installed, I'm only running git 22.214.171.124. The problem is that I have another version of Git installed. If I run which Git, you can see that we're getting this from the /user/bin folder, whereas Homebrew stores it in the user/local/bin folder. Either I've installed Git in another way in the past, or this is a version of Git that comes built in with Mac OS 10. In either case, I wanna ignore this version and use the version I installed via Homebrew. The problem is in the path variable. If I echo $PATH, you'll see that user/local/bin comes in our half variable after /user/bin. So once the terminal finds Git in the /user/bin, it doesn't continue looking to to see that there's a version in /user/local/bin. So i'm just gonna copy /user/local/bin right now, and what i'm gonna do is just append it to the front of the path and it won't mater that it shows up multiple times in the path, but will still be able to use the version that we installed with Homebrew. So I'm gonna do this by opening up my .bash_profile file. And I'm just going to write export PATH, and then I'm going to export that "/user/local/bin:$PATH". So basically what this means is append this to the beginning to the path variable. If I save and quit this, and I could either open a new terminal, or I can just source the .bash_profile file. If I do that now, when I run which Git, you can see that I'm using /user/local/bin/git, and if I run git --version, I have git 1.7.10 as the version I'm using. So that is great. However, if you don't want to use the Homebrew version, you can come to the git website, git-scm.com. This has been beautifully redesigned pretty recently. In fact, I've actually had to re-record this video since I started creating this video series. Because the old Git website was pretty old and honestly pretty ugly compared to this really nice well-designed thing that they've given us now. You can come to this new git-scm website, and right down here it recognizes that we're on a Mac, and it allows us to download the latest stable release, 126.96.36.199, and right away, it's going to start downloading that. I'll press Keep, and it'll go ahead and download. Now, that that has finished downloading, I'm gonna click it to mount it, and we can see that this is the drive that we get. We have this package here that we can double click to install, and then we just walk through those steps very simply, there's really no options. I'm not gonna actually give it my password because I don't want to go ahead and install this, because I all ready have Git installed, but if you go ahead and install it you will find that you're really not gonna have any troubles at all. So that is installing Git on the Mac. Now, we actually want to install Git on our Windows computer. So to do that, we'll start by heading over to git-scm.com just like we did before with the Mac. However, you'll notice that this time, it's actually noticed that we're on a Windows computer, and it has the option to download for Windows here, so that's great. I'll go ahead and click Download for Windows, and as you can see, we're taken to a download page and the download actually begins automatically. Now that it's downloaded, I'm gonna go ahead and click that to install it, and then I'll go ahead and click Run. I'll have to allow it to run via user access controls, and then we'll go ahead and step through the Wizard. So I'll click Next, I'll accept the license, I'll accept the location, just leave those as default, click Next again, and now we actually come to an important command here. This is about adjusting your path environment variable, and this is all about how you wanna use Git. See, there's two ways to do this. First of all, we could run Git in our normal Windows command prompt, or we could run Git in a special prompt that Git will install just for using Git. The difference here is that, if we want to install Git, so that we can use it on a normal command prompt, it's gonna actually modify our environmental variable path, so that we can access Git from the normal command line. The third option here takes this a little bit farther. It says, we can run Git and included tools from the Windows command prompt. This will actually allow a bunch of Unix tools that are installed with Git to be accessed from our normal command prompt. And they have a warning here that says that this will override some of the Windows tools, so if you're used to using some of the Windows tools, then you probably should just stick with option two or option one. However, I prefer the Unix tools, so I'm going to go ahead and run Git and the Unix tools from the Window command prompt. So now, I'll click Next, and you have one more option to choose here, and this is configuring the line endings. Basically, Windows text files and Unix text files actually have different line ending characters. In a Unix style text file, the line ending is just a single line feed character, which you're probably used to as being a slash n. Meanwhile, on a Windows file, we need a carriage return, and a line feed character, so slash r slash n. The first one here, is probably what you wanna choose, because if you're working on any cross platform projects this is going to be what you want. This is the recommended setting for Windows. If you're working on any cross-platform projects, but you're working on Unix, you're gonna want to choose 2 here. Of course, you're not on Unix, but if you were installing on Unix you would want to work with the second one here, and then the third one here check out as is commit as is, is what you're gonna want if you're not doing any cross-platform at all. We may be doing cross-platform in the future when you work with GitHub and work with other developers via GitHub. So you're gonna want to choose number one. And I'll go ahead and click Next. And now this is going to install. Now that's finished installing. I'll just click Finish, and then I'll close our browser here. And then I can open a command prompt, and we can run git --version to see what version of Git we're using. As you can see, we are indeed running git 1.7.10, which is what we installed, and therefore we have Git properly installed on our Windows computer. So now that we've installed Git on both our Mac or Windows computer, we're ready to do some configuration to get it ready to use.