So in a last lesson we looked at how we can push our local repository to a remote repository on Git 1
Hub. 2
Now in this lesson I want to talk about cloning a remote repository to pull it into your local machine. 3
So this is called cloning or the command would be git clone and that is a way for you to pull down all 4
of the commits and all of the versions of a particular remote repository and to store the files inside 5
your working directory. 6
So let's give it a go and see how it works in practice. 7
So inside GitHub if you search for open source iOS apps, you can actually see a collaborative list 8
of really awesome open source iOS apps. 9
So this is the place where you can browse by category and you can look at all the projects that people 10
have made 11
open source on GitHub. And you can maybe learn from how they format their code or how they write things 12
and it's a really really good resource that I would recommend you to bookmark. 13
So let's take a look at one of these projects so we can see their commit history so that we can clone 14
it to our local machine. 15
So this is a really cool repository. 16
This is the game 2048 that this guy Austin Zheng has created. 17
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
a go. 19
So let's try and do that. 20
So the first thing we're going to go to is this button where it says clone or download. 21
Now previously when we've been asking you to download our skeleton project because we haven't yet covered 22
Git or GitHub, we've always asked you to simply download the zip and unzip it. 23
Now this is not as great an option as using git clone. 24
So that's what we're going to do. 25
So if we copy the URL of this particular repository then we can go back into our terminal and clone 26
it to our desktop. 27
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
and then I'm going to paste that URL that I copied earlier on. 29
So now if I hit enter then it's going to clone into my very own local working directory, swift 2048 and 30
it didn't even take that long because it's actually quite small. 31
So now if I have a look at my desktop I can see this folder. 32
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
all of the project files inside swift 2048 as well as the swift Xcode project. 34
So let's go ahead and double click it to launch it and let's see if it works. 35
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
things. 37
Now if you wanted to run this or anything that you clone from the from GitHub then you obviously have 38
to change your bundle identifier and also change your team. 39
But right now I'm not going to mess with it because I'm just going to run in my simulator 40
so these things don't matter so much. 41
All right. 42
So here's the app and I can already hit start game. So you can click and pull down to swipe down and 43
click to rights to swipe right. 44
And you can see that this is a beautiful implementation of the 2048 game. 45
So it works absolutely perfectly 46
and if you decide to go ahead and change the bundle identifier and also add your team, then you can actually 47
run it on your phone and play with it. 48
But more importantly you can have a look inside the code files and see how exactly did they achieve 49
this, 50
you know what is their coding style, what are some of the things that they used to create this game. 51
So that was a quick demonstration of git clone. 52
And the other thing that you should realize is that once you've cloned a project and you cd into it, 53
so let's go inside that project. 54
You can also use git log to check out some of their previous commits and you can see they've got all 55
these commit messages that tell you what each commit was all about. 56
All right. 57
So that was a little bit on git cloning. 58
So in the future when you need to grab any of the skeleton projects from our GitHub repository then 59
you'll know what to do. 60
Then you'll be able to use git clone to grab it and download it on to your local system. 61
So in the next lesson, I'm going to be talking about something slightly more advanced. I'm going to be talking 62
about forking, making pull requests and merging repositories. 63
So all of that is yet to come. 64
So I'll see you on the next lesson.