Watch videos with subtitles in your language, upload your videos, create your own subtitles! Click here to learn more on "how to Dotsub"

Install Git

0 (0 Likes / 0 Dislikes)
♪♫♫♪♫♫♪♪♫♫♪ In this next video we're going to be learning how to use a really important tool in the Drupal community. We store all of our code in a version control system called Git. So in order to be able to use the latest development versions people are working on and to help modify those and make changes and test the changes that others are making, we need to use Git to get a copy of our code rather than just downloading that zip or tarball that you normally would. So in this lesson we're going to be looking at how to install Git on your local computer, and then we'll cover some basic Git commands to get you sort of comfortable with it and show you how to use Git to download the latest development version of Drupal 8. So to begin we'll start at a Drupal ladder and we'll move up to the second step which is install Git. I'm going to click on that link, you'll see that we get to a page that actually has quite a lot of information on it. So we're going to break this into three sections. And we're going to start off with installing Git and getting that set up and ready. So when we scroll to that section on the page you'll see there's instructions for Windows, Mac and Linux, but regardless of which operating system you're using you're going to go to git-scm.com for the downloads, and on the downloads page you'll see that it's auto-detecting that I'm on Windows, but the other operating systems are available, so there's Mac. There's also Linux. Now for Linux if you click on this you're going to find text instructions for what commands to run. There's not a downloadable package for that. But we do have Solaris and Linux instructions. We have Windows. I'm on Windows, mostly because there's sort of the most steps involved with Windows. I'm going to save the file to .exe and then I'll open it up once I have it downloaded. And this opens up the installation wizard, and pretty much we're going to be able to just leave the defaults as we go through here. It's your classic kind of setup for a new program that you're installing, where you want it to be, what shortcuts you want and that kind of a thing. So I'm going to go ahead and leave these at defaults although we will talk about one of the options when we get there. So I can leave these. And now we're going to get to a screen that's going to talk about our path environment. In this download Windows provides a program called Git Bash, which will let us use Git just like you would on a Linux system. We could change to be able to use Git from the regular Windows command prompt which you would definitely want to do if you were using something like Cygwin and you wanted to be able to sort of run bash things in your regular terminal We don't really need to do that and in this instance I'm just going to use the Git Bash program that comes with this installation of Git as that's really straightforward and should cover our needs. And the rest of this stuff I'm going to leave again at its default and just continue and finish up the installation. I do not want to see release notes I'm going to turn that off and we'll finish. So now I have that installed locally and if I minimize my browser here you'll see that the default setting was to put a shortcut to Git Bash on my desktop, which is great. So I'm going to go ahead and launch that and lets type the word "git" and hit enter, and I'm getting a whole bunch of help information on the various commands that are available. That means Git is working So we have it installed and Git is actually working. So that has us with a good start. If we go back to the instructions, we scroll down a little bit. You're going to see that there's some next steps with Git. And there's some basic configuration that we want to take care of just to make sure we're all ready to go. They're just copy and paste lines so what I'll need to do is go into my Git Bash or if you're on Mac or Linux you would just open up your terminal, and we're going to go ahead and do these commands so we can get things set up properly. So let me move this kind of out of the way here so I can see what I'm doing. And I'm going to go ahead and clear my screen. And so we just basically we just need to put these commands just as they are so first I need to do the Git config and then dash dash global doesn't mean for all users, it means every instance where this user's doing something globally within Git, not per project. So I'm going to do a global configuration for this user and put my name in. So when I do a commit my name will be associated with it. We need to do a similar thing with email. So in the Git world having your identifying your work with your commits with your name and email address is the standard and so want to set ourselves up to do that properly. So I'll go ahead and put my email address in here. And then last thing is just these line endings, differences between Windows and Linux we're just going to go ahead and set that just to make sure we don't mess up anybody else's work because of our line endings. So if we look at our instructions here it's telling me that this configuration is in my home directory somewhere so let's go take a look and see what happened when we typed those commands, 'cause we didn't see anything on this screen. So I'm going to go into my home directory. I'm the administrator user here. And you'll see there's this file with no name. It's a Git config file. The name of the file is .gitconfig which makes it hidden so you'll need to be able to see hidden files to see it. And then if I go in and open this up with a regular text editor you'll see it's just a text file and the things that I typed into the screen and saw no response, were actually getting written into this file. So that's where my configuration stuff is actually stored. So, we have Git, now let's use it to download a Drupal project and see how that works. So if we scroll down the page here we'll see that we have instructions for downloading a project. There are also instructions for downloading Drupal itself, which we'll get to in the next section. So let's just go ahead and follow the instructions here. First of all we need to make sure we're in the right place. We want to download a module into the modules directory, or a theme into the themes directory. So this is telling me I need to make sure that I'm in the right location because wherever I run the command is where stuff's going to get downloaded. So I'm going to see where I am. Which I'm currently in my "home" directory. And I'm going to move into where my web root is. Which for me is a directory called "websites"; wherever it is for you. And I have a Drupal 7 installation here so I'm in my Drupal 7 installation and of course we always put our modules in "sites/all/modules" So I'm going to move into that directory using "cd" and "ls". These are bash commands, again I'm on Git Bash and not a regular Windows terminal. So I'm in the right place, now let's go find a project. And I'm going to use "Admin menu" as the example here. This is a module I want to download and use on my site and I want to get it using git. So I go to the version control tab all the projects on drupal.org have this. I can pick which version I want it's the 7, I'm using Drupal 7 so I need the 7 version and the 3.x branch would appear to be the most current. And so the instructions that are down here are for me to be able to get them. So basically I just need to be able to copy and paste this. So let me highlight and copy this line. I'm going to "git clone", clone is how you would download a new git project. I'll go into my Git Bash and I'm going to go ahead and just paste that in so I don't have to type it, and hit "enter". And that's going to begin the clone process, which can take a few minutes depending on the size of the project. So I'll let that do what it needs to do, and then once we're done if I do "ls" to list you'll see I now have "admin menu" in my modules directory. And if I go inside of that folder, I actually have the admin menu module. Handy dandy And now I can go enable it and use that module just like anything else. So now that we have a git checkout lets play around with some basic commands. So "git status" is a good one. I can see which branch I'm on, and if I've made any changes locally. Another good one is "git branch" and I do dash "a" (-a) on that and I see not just what my local branch is but also anything that's remote up on drupal.org. So I can see all of the ones that are available, and the one with the star (*) is the one I'm using, which is the 7.3x that I just cloned and then another good basic command to be able to use is "git log". And if I put a dash 3 (-3) after the end it will only bring up the last three commits. So the log is a list of all of the commits so I can see the history of what's going on in this particular branch. So the last three commits are listed here. And I could five or ten or whatever I want. Ok so now let's take a look at downloading Drupal core with git and we're going to download the latest development version of Drupal 8. So, first of all, again I need to make sure I'm in the right location I don't want to download core into my modules directory in another site I want to start a new site. So I need to go back to my web root you can see the Drupal 7 site I was working on and I'm going to put Drupal 8 next to it. And if we go back to drupal.org, I'm going to go to the Drupal core project page. And again it has a "version control" tab just like any other project. And when I click there, again I can pick the version, and I want to get the 8.x version which is the latest development work that is going on. And then I can come down and then I can get my clone command for getting that so, copy that. And go back over here to get Git Bash again, just want to make sure I'm in the right place so I'm in my web root directory, where all my websites live. Top level, and then I just need to go in here and paste this command. Do my fun, Git Bash program pasting here. Hit "enter". This is going to take longer than the admin module download did. So it's going to take a little bit of time so just have some patience while it downloads/clones all the files that it needs. And now if I list (ls) you'll see I have Drupal, it just downloads it to a folder called "drupal". I can change that name if I want to. I'll go inside and when I list (ls) the contents you'll see it looks quite different. Drupal 8's file directory structure is different than Drupal 7, so I definitely know I have the right thing. So that's how we use git to get the latest development version of Drupal, and now since I'm using git I can do things like apply patches and create my own patches and help other people with testing and working on making Drupal 8 even better.

Video Details

Duration: 11 minutes and 43 seconds
Country: United States
Language: English
License: All rights reserved
Genre: None
Views: 46
Posted by: drupalizeme on Jul 18, 2012

In this video we walk through getting Git version control installed, and then show how to do a few basic things, including how to get a copy of the latest Drupal development code. This video follows the instructions found in the Install Git lesson on learndrupal.org.

Caption and Translate

    Sign In/Register for Dotsub to translate this video.