WEBVTT 0 00:00.620 --> 00:08.180 So in a last lesson we looked at how we can push our local repository to a remote repository on Git 1 00:08.180 --> 00:09.170 Hub. 2 00:09.170 --> 00:17.140 Now in this lesson I want to talk about cloning a remote repository to pull it into your local machine. 3 00:17.330 --> 00:26.360 So this is called cloning or the command would be git clone and that is a way for you to pull down all 4 00:26.360 --> 00:33.860 of the commits and all of the versions of a particular remote repository and to store the files inside 5 00:33.950 --> 00:35.690 your working directory. 6 00:35.690 --> 00:38.320 So let's give it a go and see how it works in practice. 7 00:38.450 --> 00:44.360 So inside GitHub if you search for open source iOS apps, you can actually see a collaborative list 8 00:44.780 --> 00:48.060 of really awesome open source iOS apps. 9 00:48.080 --> 00:54.740 So this is the place where you can browse by category and you can look at all the projects that people 10 00:54.740 --> 00:55.300 have made 11 00:55.330 --> 01:03.170 open source on GitHub. And you can maybe learn from how they format their code or how they write things 12 01:03.230 --> 01:08.070 and it's a really really good resource that I would recommend you to bookmark. 13 01:08.090 --> 01:15.380 So let's take a look at one of these projects so we can see their commit history so that we can clone 14 01:15.380 --> 01:17.900 it to our local machine. 15 01:17.900 --> 01:20.170 So this is a really cool repository. 16 01:20.180 --> 01:27.160 This is the game 2048 that this guy Austin Zheng has created. 17 01:27.350 --> 01:35.540 And we can port it onto our own system and we can have a look at the code or simply run it and give it 18 01:35.540 --> 01:36.130 a go. 19 01:36.350 --> 01:37.710 So let's try and do that. 20 01:37.820 --> 01:42.740 So the first thing we're going to go to is this button where it says clone or download. 21 01:42.770 --> 01:49.700 Now previously when we've been asking you to download our skeleton project because we haven't yet covered 22 01:49.810 --> 01:55.220 Git or GitHub, we've always asked you to simply download the zip and unzip it. 23 01:55.310 --> 01:59.260 Now this is not as great an option as using git clone. 24 01:59.450 --> 02:00.530 So that's what we're going to do. 25 02:00.530 --> 02:09.680 So if we copy the URL of this particular repository then we can go back into our terminal and clone 26 02:09.680 --> 02:11.470 it to our desktop. 27 02:11.660 --> 02:18.980 So at the moment I am in my desktop and all I'm going to do is I'm going to use the command git clone 28 02:20.090 --> 02:23.390 and then I'm going to paste that URL that I copied earlier on. 29 02:23.480 --> 02:33.530 So now if I hit enter then it's going to clone into my very own local working directory, swift 2048 and 30 02:33.560 --> 02:36.680 it didn't even take that long because it's actually quite small. 31 02:36.710 --> 02:40.120 So now if I have a look at my desktop I can see this folder. 32 02:40.220 --> 02:45.620 So this is the project that I've just cloned down from GitHub. So if you double click on it then you can see 33 02:45.680 --> 02:52.730 all of the project files inside swift 2048 as well as the swift Xcode project. 34 02:52.730 --> 02:59.390 So let's go ahead and double click it to launch it and let's see if it works. 35 03:02.760 --> 03:08.490 So I'm actually going to try and run it locally on my simulator so I'm not going to change any of these 36 03:08.490 --> 03:08.930 things. 37 03:08.940 --> 03:16.500 Now if you wanted to run this or anything that you clone from the from GitHub then you obviously have 38 03:16.500 --> 03:20.610 to change your bundle identifier and also change your team. 39 03:20.610 --> 03:24.900 But right now I'm not going to mess with it because I'm just going to run in my simulator 40 03:25.020 --> 03:27.440 so these things don't matter so much. 41 03:28.600 --> 03:28.860 All right. 42 03:28.870 --> 03:38.080 So here's the app and I can already hit start game. So you can click and pull down to swipe down and 43 03:38.170 --> 03:41.100 click to rights to swipe right. 44 03:41.260 --> 03:46.050 And you can see that this is a beautiful implementation of the 2048 game. 45 03:46.180 --> 03:48.580 So it works absolutely perfectly 46 03:48.580 --> 03:56.320 and if you decide to go ahead and change the bundle identifier and also add your team, then you can actually 47 03:56.320 --> 03:58.490 run it on your phone and play with it. 48 03:58.660 --> 04:04.060 But more importantly you can have a look inside the code files and see how exactly did they achieve 49 04:04.090 --> 04:04.710 this, 50 04:04.730 --> 04:09.760 you know what is their coding style, what are some of the things that they used to create this game. 51 04:09.820 --> 04:12.980 So that was a quick demonstration of git clone. 52 04:13.210 --> 04:21.050 And the other thing that you should realize is that once you've cloned a project and you cd into it, 53 04:21.160 --> 04:23.140 so let's go inside that project. 54 04:23.170 --> 04:29.170 You can also use git log to check out some of their previous commits and you can see they've got all 55 04:29.170 --> 04:33.680 these commit messages that tell you what each commit was all about. 56 04:33.820 --> 04:34.110 All right. 57 04:34.120 --> 04:36.150 So that was a little bit on git cloning. 58 04:36.160 --> 04:43.720 So in the future when you need to grab any of the skeleton projects from our GitHub repository then 59 04:43.750 --> 04:44.940 you'll know what to do. 60 04:44.980 --> 04:50.770 Then you'll be able to use git clone to grab it and download it on to your local system. 61 04:50.770 --> 04:55.660 So in the next lesson, I'm going to be talking about something slightly more advanced. I'm going to be talking 62 04:55.660 --> 05:00.800 about forking, making pull requests and merging repositories. 63 05:00.940 --> 05:03.030 So all of that is yet to come. 64 05:03.040 --> 05:04.370 So I'll see you on the next lesson.