1 00:00:00,410 --> 00:00:04,050 Our project for this course will be a simplified version of a website for 2 00:00:04,050 --> 00:00:08,810 a company that makes gold, silver, and bronze medals to award at sporting events. 3 00:00:08,810 --> 00:00:12,810 If you launch a Treehouse workspace using the button on this videos page, you'll see 4 00:00:12,810 --> 00:00:17,310 a medals directory, directory's a fancy world for folder, with two files in it. 5 00:00:17,310 --> 00:00:20,880 A medals.html file that holds the main page content, and 6 00:00:20,880 --> 00:00:25,670 a bronze.html file that holds information on the store's bronze medals. 7 00:00:25,670 --> 00:00:29,220 You don't need to worry too much about the particular content of these files. 8 00:00:29,220 --> 00:00:32,970 If you really want to know more about html, you can see the teacher's notes for 9 00:00:32,970 --> 00:00:34,050 more info. 10 00:00:34,050 --> 00:00:38,450 The important part is the git commands we'll be using to track their contents. 11 00:00:38,450 --> 00:00:41,370 Because we'll be making many of our changes using the console, 12 00:00:41,370 --> 00:00:44,908 the sidebar may not display what the directory actually holds all the time. 13 00:00:44,908 --> 00:00:49,850 You can right-click on the sidebar and choose to refresh the list, but 14 00:00:49,850 --> 00:00:51,690 I don't want to do that over and over. 15 00:00:51,690 --> 00:00:55,390 So I'm going to the View menu and choose Hide Sidebar. 16 00:00:55,390 --> 00:00:59,720 When I need the sidebar later, I'll use the Show Sidebar menu to reveal it again. 17 00:00:59,720 --> 00:01:02,640 For the most part, I'll be using simple commands that let us look at 18 00:01:02,640 --> 00:01:05,260 the contents of the directory from the console. 19 00:01:05,260 --> 00:01:08,530 There's two ways to get a git repository onto your computer. 20 00:01:08,530 --> 00:01:12,200 One is to clone, or copy, a repo from another machine. 21 00:01:12,200 --> 00:01:14,010 We'll look at this later in the course. 22 00:01:14,010 --> 00:01:18,510 The other is to create a repository within a project directory on your computer. 23 00:01:18,510 --> 00:01:19,980 That's what we'll do here. 24 00:01:19,980 --> 00:01:22,910 Right now we're in the workspace directory which holds all of the files for 25 00:01:22,910 --> 00:01:24,410 this workspace. 26 00:01:24,410 --> 00:01:26,830 We need to change into our project directory so 27 00:01:26,830 --> 00:01:28,450 we can turn it into a Git repo. 28 00:01:29,450 --> 00:01:32,170 So I'll click down in the console to activate it. 29 00:01:32,170 --> 00:01:36,630 And now if we type ls and press Enter, it will run the ls command. 30 00:01:36,630 --> 00:01:40,550 This lists files and directories within the current directory. 31 00:01:40,550 --> 00:01:44,695 By the way, the ls command isn't part of git, but it's a standard command on all 32 00:01:44,695 --> 00:01:49,540 Unix-like systems, such as Mac, Linux, and the subsystem for Linux on Windows. 33 00:01:49,540 --> 00:01:51,650 It's worth your time to learn how to use it. 34 00:01:51,650 --> 00:01:54,120 We'll have more info in the teacher's notes. 35 00:01:54,120 --> 00:01:58,230 We can see our project directory, medals, in the output of ls. 36 00:01:58,230 --> 00:02:03,740 To get into the medals directory, we'll use the cd or change directory command. 37 00:02:03,740 --> 00:02:04,970 Then we tap a space, 38 00:02:04,970 --> 00:02:09,310 followed by the name of the directory we want to change into, medals. 39 00:02:09,310 --> 00:02:12,685 We can see that the directory name in our shell prompts has changed to 40 00:02:12,685 --> 00:02:15,010 workspace/medals. 41 00:02:15,010 --> 00:02:18,890 And if we run again, we will see the files for our project. 42 00:02:18,890 --> 00:02:22,770 Now that we are in the project directory, we need to initialize the new repository. 43 00:02:22,770 --> 00:02:26,105 We will do this with the git init command. 44 00:02:26,105 --> 00:02:28,940 Like all the git commands we'll be using in this course, 45 00:02:28,940 --> 00:02:32,440 it starts with the name of the git executable followed by a space. 46 00:02:32,440 --> 00:02:36,390 Then we type the name of the sub command we want to run like add or commit. 47 00:02:36,390 --> 00:02:38,030 Or in this case, init. 48 00:02:38,030 --> 00:02:41,000 That's the whole command, so press Enter to run it. 49 00:02:41,000 --> 00:02:43,840 It will initialize a repository in the current directory 50 00:02:43,840 --> 00:02:47,730 by creating a new directory named .git within it, 51 00:02:47,730 --> 00:02:49,420 or at least it's supposed to, 52 00:02:49,420 --> 00:02:53,240 but if we run ls again, we don't see a .git directory. 53 00:02:53,240 --> 00:02:56,050 This is because the file name begins with a dot. 54 00:02:56,050 --> 00:02:57,440 On Unix-like systems, 55 00:02:57,440 --> 00:03:01,890 such as Linux, a dot at the start of a filename means that the file is hidden. 56 00:03:01,890 --> 00:03:04,030 Let's show the sidebar and refresh it. 57 00:03:06,070 --> 00:03:08,610 That Git directory won't appear there either. 58 00:03:08,610 --> 00:03:12,900 But ls has a special command line option that will cause it to show all files, 59 00:03:12,900 --> 00:03:14,420 even hidden ones. 60 00:03:14,420 --> 00:03:18,190 Options to other commands work just like the options for the git executable. 61 00:03:18,190 --> 00:03:21,765 We type ls, a space, and then the option we want, -a. 62 00:03:21,765 --> 00:03:26,590 The -a stands for all, as in list all files. 63 00:03:26,590 --> 00:03:31,340 If we hit Enter to run it, we can see the .git directory in the output of ls. 64 00:03:31,340 --> 00:03:34,860 But why would git create this directory only to hide it from us? 65 00:03:34,860 --> 00:03:38,520 The reason is that you generally don't want to directly interact with the .git 66 00:03:38,520 --> 00:03:39,620 directory. 67 00:03:39,620 --> 00:03:42,890 It stores all of your repository's history in a special format 68 00:03:42,890 --> 00:03:46,050 that only the git command really knows how to update safely. 69 00:03:46,050 --> 00:03:50,130 You do not want to modify the files in the .git directory yourself. 70 00:03:50,130 --> 00:03:52,260 You could corrupt your repository's history, 71 00:03:52,260 --> 00:03:56,165 meaning you would lose everything that hadn't been cloned to other computers. 72 00:03:56,165 --> 00:03:58,285 Don't worry, that isn't a common problem. 73 00:03:58,285 --> 00:04:01,575 It's rare for people to modify the contents of .git directly, 74 00:04:01,575 --> 00:04:03,545 either accidentally or on purpose. 75 00:04:03,545 --> 00:04:06,035 It just explains why the directory is hidden. 76 00:04:06,035 --> 00:04:08,665 But it's much safer to modify the .git directory 77 00:04:08,665 --> 00:04:11,485 indirectly by making commits through the git command. 78 00:04:11,485 --> 00:04:13,305 We'll do just that in the next video.