1 00:00:00,060 --> 00:00:02,670 So the first thing we're going to cover is cloning. 2 00:00:02,700 --> 00:00:06,450 Cloning is a really important part of working with remote repositories. 3 00:00:06,660 --> 00:00:12,330 In fact, it's such an important thing that we do and get if we go to the documentation under reference, 4 00:00:12,720 --> 00:00:18,330 all the commands are grouped together like the basic snapshot and commands adding and get status, get 5 00:00:18,330 --> 00:00:20,630 commits, branching and merging. 6 00:00:20,640 --> 00:00:21,870 They're grouped together. 7 00:00:21,870 --> 00:00:29,370 But then up top there are two commands side by side, getting and creating projects init and clone. 8 00:00:29,880 --> 00:00:34,340 So we've seen how to use git init to create a new project or a new repo from scratch. 9 00:00:34,350 --> 00:00:39,000 We've done that for every repository but get clone does something different. 10 00:00:39,030 --> 00:00:46,620 Git clone actually goes and gets a repository that is not on your machine and it brings it to your machine. 11 00:00:46,650 --> 00:00:51,960 It basically downloads the contents of a repository based upon some URL that we provide. 12 00:00:52,350 --> 00:00:56,910 Typically, that URL will be from a service like GitHub. 13 00:00:56,910 --> 00:01:03,540 And in this course and 99% of the open source projects out there, it will be a GitHub repository that 14 00:01:03,540 --> 00:01:05,700 you're cloning, but it could be something else. 15 00:01:05,700 --> 00:01:09,480 Bitbucket It could be a self-hosted repository. 16 00:01:09,510 --> 00:01:10,830 Git does not care. 17 00:01:11,160 --> 00:01:13,320 The command get clone is part of Git. 18 00:01:13,350 --> 00:01:14,940 It's not part of GitHub. 19 00:01:15,480 --> 00:01:16,350 So here it is. 20 00:01:16,350 --> 00:01:18,570 Get Clone and then a URL. 21 00:01:18,870 --> 00:01:25,500 And that URL is where git will go and retrieve all the relevant information for repository from it. 22 00:01:25,500 --> 00:01:27,390 Will copy the files to your machine. 23 00:01:27,390 --> 00:01:33,480 It initializes a new repository on your machine so that gives you access to the full git history of 24 00:01:33,480 --> 00:01:35,130 whatever project you're cloning. 25 00:01:35,130 --> 00:01:36,960 And I'm going to demo this in just a moment. 26 00:01:37,530 --> 00:01:40,920 So as an example, there's some repository on GitHub. 27 00:01:40,920 --> 00:01:46,530 Let's say it's I don't know, it's it's React or it's a Flappy Bird clone. 28 00:01:46,530 --> 00:01:48,510 It's some game on GitHub. 29 00:01:48,990 --> 00:01:51,600 I want the source code and the get history. 30 00:01:51,600 --> 00:01:58,410 So if I run Git clone with the corresponding URL, whatever that GitHub URL is for that hosted repo, 31 00:01:58,980 --> 00:02:02,850 git is going to go fetch all of that and bring it down to my machine. 32 00:02:03,030 --> 00:02:08,910 I'll have the full history, all the commits, all the files, so I'll go ahead and demonstrate this. 33 00:02:09,090 --> 00:02:12,480 Here's a GitHub repository that I don't have. 34 00:02:12,690 --> 00:02:20,220 It's for the game 2048, which some of you probably know this game very addictive. 35 00:02:20,460 --> 00:02:27,510 It's I don't know how many years old now, but anyway, it's just a JavaScript, HTML, CSS that it's 36 00:02:27,510 --> 00:02:27,780 a game. 37 00:02:27,780 --> 00:02:29,670 You can open it up and play it in your browser. 38 00:02:29,880 --> 00:02:35,340 So if I want the code for that and I want the full git history, of course I can see it on GitHub. 39 00:02:35,610 --> 00:02:37,320 That's what GitHub is doing for me here. 40 00:02:37,320 --> 00:02:44,040 As a user, I can view this URL, I can look at different commits, 180 commits, I can see who contributed. 41 00:02:44,040 --> 00:02:45,390 I can read about it. 42 00:02:45,390 --> 00:02:52,350 I can take a look at the index HTML file in the browser, but I'm going to clone this URL. 43 00:02:52,380 --> 00:02:55,080 One option is just to copy this URL right here. 44 00:02:55,080 --> 00:03:00,780 Another option on GitHub is to click right here and it's going to show me the clone URL, which is the 45 00:03:00,780 --> 00:03:01,980 same thing as we see up there. 46 00:03:01,980 --> 00:03:07,260 I can click this button, I can command see however you want to get that URL, I'm going to get that 47 00:03:07,260 --> 00:03:07,950 URL. 48 00:03:08,280 --> 00:03:11,820 And by the way, this repository link is in the resources with this video. 49 00:03:11,820 --> 00:03:14,250 If you want to try this, definitely recommend you do. 50 00:03:14,940 --> 00:03:17,100 Now I'm going to go over to my terminal. 51 00:03:17,100 --> 00:03:21,360 The first thing you always want to do when you're cloning is make sure that you're not in a repository 52 00:03:21,360 --> 00:03:23,070 just like when you run git init. 53 00:03:23,070 --> 00:03:25,290 So I just like to do get status. 54 00:03:25,830 --> 00:03:32,670 We're not in a repository and then wherever you run git clone that is the place that folder where Git 55 00:03:32,670 --> 00:03:35,010 is going to create a new folder for you. 56 00:03:35,010 --> 00:03:38,160 So I'm in a folder called what is this? 57 00:03:38,520 --> 00:03:39,150 Just. 58 00:03:39,540 --> 00:03:42,030 Well, actually, I meant to be in this folder cloning. 59 00:03:42,030 --> 00:03:43,680 So now I'm in a folder cloning. 60 00:03:43,890 --> 00:03:44,970 There's nothing in here. 61 00:03:44,970 --> 00:03:51,150 It's going to make me a new folder when I run this command git clone and then I paste the URL that's 62 00:03:51,150 --> 00:03:52,200 coming from GitHub. 63 00:03:52,410 --> 00:03:54,870 I don't have anything from this URL. 64 00:03:54,870 --> 00:03:57,330 I don't have this repository on this machine. 65 00:03:57,330 --> 00:03:58,770 I'm not in a git repo. 66 00:03:59,490 --> 00:04:05,700 But when that finishes and you will need Internet for this, when that finishes, we see a new folder 67 00:04:05,700 --> 00:04:08,850 that was not there before I typed ls there was nothing. 68 00:04:09,180 --> 00:04:15,680 If I go into that folder and I type ls OC I've got a whole bunch of stuff, right? 69 00:04:15,690 --> 00:04:22,019 I've got index, HTML, JavaScript, folder, style folder, some other stuff going on. 70 00:04:22,019 --> 00:04:26,020 And it looks like this is a git repo, right? 71 00:04:26,040 --> 00:04:27,420 If I type get status. 72 00:04:27,600 --> 00:04:29,040 Yes, it is. 73 00:04:29,040 --> 00:04:32,910 If I type git log, I can see the full history of commits. 74 00:04:33,750 --> 00:04:34,920 See all that stuff. 75 00:04:35,190 --> 00:04:35,970 That's all. 76 00:04:36,180 --> 00:04:37,480 Or it came from GitHub. 77 00:04:37,500 --> 00:04:40,800 I can see all the commits and who made them when they were made. 78 00:04:41,610 --> 00:04:43,230 There's all the code here. 79 00:04:43,230 --> 00:04:45,220 I can open it up and take a look. 80 00:04:45,240 --> 00:04:46,680 I can even run this. 81 00:04:47,220 --> 00:04:49,080 And there this is actually running. 82 00:04:49,410 --> 00:04:50,810 This is not the hosted version. 83 00:04:50,820 --> 00:04:51,960 This is running from my machine. 84 00:04:51,960 --> 00:04:54,590 You can see here and there we are. 85 00:04:54,600 --> 00:04:56,320 I could play around with it myself. 86 00:04:56,340 --> 00:04:57,930 I could change the styles. 87 00:04:58,020 --> 00:05:05,310 I've opened up the CSS, main CSS, and I could do something like a sort of background. 88 00:05:05,460 --> 00:05:08,580 What are we doing with the background color somewhere? 89 00:05:08,630 --> 00:05:09,570 Oh, there we are. 90 00:05:09,600 --> 00:05:14,310 Let's make that some form of green or olive. 91 00:05:14,340 --> 00:05:14,930 Sure. 92 00:05:14,940 --> 00:05:17,010 All live just like that. 93 00:05:17,250 --> 00:05:19,950 So pretend I've tweaked a whole bunch of things. 94 00:05:20,250 --> 00:05:21,930 I can see those changes, right? 95 00:05:21,930 --> 00:05:24,660 This is all just for me to experiment and play around with locally. 96 00:05:24,660 --> 00:05:29,670 Although in the next couple of sections I'll also show how we could make changes and then try and contribute. 97 00:05:29,700 --> 00:05:33,060 Try and share these changes with the owner of the repository. 98 00:05:33,090 --> 00:05:39,060 Try and suggest maybe not this, but maybe there's a bug that someone's identified and I volunteered 99 00:05:39,060 --> 00:05:39,780 to fix it. 100 00:05:40,050 --> 00:05:45,330 I would need to clone the repository, whether I'm just messing around and breaking things and playing 101 00:05:45,330 --> 00:05:49,920 and changing colours, whether I'm trying to understand how something works or whether I want to make 102 00:05:49,920 --> 00:05:52,560 contributions I need to clone. 103 00:05:52,800 --> 00:05:54,840 So that command git clone. 104 00:05:55,020 --> 00:05:56,210 It's pretty simple, right? 105 00:05:56,220 --> 00:05:57,840 Just get clone and then a URL. 106 00:05:57,870 --> 00:06:03,180 Make sure you're not in a git repository when you run it because it creates well, it creates a folder. 107 00:06:03,180 --> 00:06:08,760 But in that folder there is a git repository that's been initialized and it has the full history of 108 00:06:08,760 --> 00:06:09,660 the project. 109 00:06:09,870 --> 00:06:12,420 I'm just showing it to you and get cracking very quickly. 110 00:06:12,420 --> 00:06:19,320 This is the cloned repository and we can see a lot of commits going on as I scroll, a lot of different 111 00:06:19,320 --> 00:06:24,330 branches over time, a lot of different contributors, and I could take a look at any of them. 112 00:06:24,510 --> 00:06:26,490 I could go all the way back to the beginning. 113 00:06:26,640 --> 00:06:33,240 Oh, boy, look, initial commit, basic styling, the very basic stuff like add wind win conditions 114 00:06:33,240 --> 00:06:38,850 so you can win the game all the way up to things up top where other developers have contributed. 115 00:06:39,420 --> 00:06:40,920 I'll just show one more example. 116 00:06:40,920 --> 00:06:42,990 This is another GitHub repository. 117 00:06:43,290 --> 00:06:45,300 This one is just a list. 118 00:06:45,300 --> 00:06:52,350 It's a list of companies that hire without whiteboarding interviews, without the bad computer science 119 00:06:52,350 --> 00:06:56,130 trivia questions that don't actually test your abilities as a developer. 120 00:06:56,130 --> 00:06:56,940 It's open source. 121 00:06:56,940 --> 00:06:59,330 People contribute different companies that are on here. 122 00:06:59,340 --> 00:07:05,880 If I want this repository for whatever reason on my machine, never mind the fact that you just it's 123 00:07:05,880 --> 00:07:07,470 probably easier to view it here. 124 00:07:07,470 --> 00:07:11,340 But if I wanted to contribute an ad, I could copy this URL. 125 00:07:11,610 --> 00:07:11,910 Right? 126 00:07:11,940 --> 00:07:18,360 Or I can click here and copy that there the same URL go to my terminal, which is somewhere there we 127 00:07:18,360 --> 00:07:18,750 are. 128 00:07:19,440 --> 00:07:25,290 Make sure I'm not in a get repo and I am right now so I'm going to back out and now I'm not type get 129 00:07:25,290 --> 00:07:29,700 status I'm not get clone paste that URL. 130 00:07:31,330 --> 00:07:32,080 It takes a moment. 131 00:07:32,080 --> 00:07:33,280 This one is a bit larger. 132 00:07:33,280 --> 00:07:34,990 And then I have a new folder. 133 00:07:35,380 --> 00:07:39,000 Hiring without whiteboards get status inside. 134 00:07:39,010 --> 00:07:42,250 Yes, it is a repository I type LRS. 135 00:07:42,280 --> 00:07:49,540 We can see all the files here and I type git log and I can see all of the contributions, all the individual 136 00:07:49,540 --> 00:07:50,190 commits. 137 00:07:50,200 --> 00:07:51,130 There's quite a bit here. 138 00:07:51,130 --> 00:07:52,360 Let's do a one line. 139 00:07:55,700 --> 00:07:57,630 And then I can scroll through all of them. 140 00:07:57,650 --> 00:08:00,070 I could open this and get cracking and show you the same thing. 141 00:08:00,080 --> 00:08:03,900 I have the full history for that entire repository on my machine. 142 00:08:03,920 --> 00:08:05,540 I didn't create the repository. 143 00:08:05,540 --> 00:08:05,830 Right. 144 00:08:05,840 --> 00:08:07,880 I just cloned it using git clone. 145 00:08:07,910 --> 00:08:08,890 Great command. 146 00:08:08,900 --> 00:08:09,410 Excellent. 147 00:08:09,410 --> 00:08:11,080 Excellent, great command. 148 00:08:11,100 --> 00:08:12,760 Remember, it's a git command. 149 00:08:12,770 --> 00:08:14,360 It is not tied to GitHub.