0
1
00:00:00,670 --> 00:00:08,230
So in the last lesson, we looked at how we can push our local repository to a remote repository
1

2
00:00:08,230 --> 00:00:08,910
on GitHub.
2

3
00:00:09,220 --> 00:00:17,190
Now, in this lesson, I want to talk about cloning a remote repository to pull it into your local machine.
3

4
00:00:17,380 --> 00:00:26,410
So this is called cloning or the command would be git clone, and that is a way for you to pull down all
4

5
00:00:26,410 --> 00:00:33,910
of the commits and all of the versions of a particular remote repository, and to store the files inside
5

6
00:00:34,000 --> 00:00:35,740
your working directory.
6

7
00:00:35,740 --> 00:00:38,490
So let's give it a go and see how it works in practice.
7

8
00:00:38,500 --> 00:00:44,410
So inside GitHub, if you search for open-source iOS apps, you can actually see a collaborative list
8

9
00:00:44,830 --> 00:00:48,130
of really awesome open-source iOS apps.
9

10
00:00:48,130 --> 00:00:54,790
So this is the place where you can browse by category and you can look at all the projects that people
10

11
00:00:54,790 --> 00:00:55,370
have made
11

12
00:00:55,390 --> 00:01:03,220
open source on GitHub, and you can maybe learn from how they format their code or how they write things.
12

13
00:01:03,280 --> 00:01:08,120
And it's a really, really good resource that I would recommend you to bookmark.
13

14
00:01:08,140 --> 00:01:15,430
So let's take a look at one of these projects so we can see that commit history so that we can clone
14

15
00:01:15,430 --> 00:01:17,950
it to our local machine.
15

16
00:01:17,950 --> 00:01:20,210
So this is a really cool repository.
16

17
00:01:20,230 --> 00:01:27,400
This is the game 2048 that this guy Austin Xieng has created.
17

18
00:01:27,400 --> 00:01:35,530
And we can put it onto our own system and we can have a look at the code, or simply run it and give
18

19
00:01:35,530 --> 00:01:36,400
it a go.
19

20
00:01:36,400 --> 00:01:37,770
So let's try and do that.
20

21
00:01:37,870 --> 00:01:42,820
So the first thing we're going to go to is this button where it says Clone or download.
21

22
00:01:42,820 --> 00:01:49,750
Now, previously, when we've been asking you to download our skeleton project because we haven't yet covered
22

23
00:01:49,830 --> 00:01:55,290
Git or GitHub, we've always asked you to simply download the zip and unzip it.
23

24
00:01:55,360 --> 00:01:59,290
Now, this is not as great an option as using git clone.
24

25
00:01:59,500 --> 00:02:00,580
So that's what we're going to do.
25

26
00:02:00,580 --> 00:02:09,730
So if we copy the URL of this particular repository, then we can go back into our Terminal and clone
26

27
00:02:09,730 --> 00:02:11,690
it to our Desktop.
27

28
00:02:11,710 --> 00:02:19,030
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

29
00:02:20,140 --> 00:02:23,530
and then I'm going to paste that URL that I copied earlier on.
29

30
00:02:23,530 --> 00:02:33,580
So, now if I hit enter, then it's going to clone into my very own local working directory: swift 2048. 
30

31
00:02:33,610 --> 00:02:36,730
And it didn't even take that long because it's actually quite small.
31

32
00:02:36,760 --> 00:02:40,260
So, now if I have a look at my Desktop, I can see this folder.
32

33
00:02:40,270 --> 00:02:45,220
So this is the project that I've just cloned down from GitHub. So if you double click on it, then you can
33

34
00:02:45,220 --> 00:02:52,770
see all of the project files inside swift-2048 as well as the Swift Xcode project.
34

35
00:02:52,780 --> 00:02:59,350
So let's go ahead and double click it to launch it and let's see if it works.
35

36
00:03:02,810 --> 00:03:08,540
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

37
00:03:08,540 --> 00:03:08,970
things.
37

38
00:03:08,990 --> 00:03:16,550
Now, if you wanted to run this or anything that you clone from GitHub, then you, obviously, have
38

39
00:03:16,550 --> 00:03:20,620
to change your bundle identifier and also change your team.
39

40
00:03:20,690 --> 00:03:24,970
But right now, I'm not going to mess with it because I'm just going to run it in my simulator,
40

41
00:03:25,070 --> 00:03:27,410
so these things don't matter so much.
41

42
00:03:28,660 --> 00:03:36,160
All right. So here's the app and I can already hit start game. So you can click and pull down to swipe
42

43
00:03:36,160 --> 00:03:44,620
down, and click to right to swipe right, and you can see that this is a beautiful implementation of the
43

44
00:03:44,620 --> 00:03:46,120
2048 game.
44

45
00:03:46,240 --> 00:03:48,600
So it works absolutely perfectly.
45

46
00:03:48,610 --> 00:03:56,380
And if you decide to go ahead and change the bundle identifier and also add your team, then you can actually
46

47
00:03:56,380 --> 00:03:58,530
run it on your phone and play with it.
47

48
00:03:58,720 --> 00:04:04,150
But more importantly, you can have a look inside the code files and see how exactly did they achieve
48

49
00:04:04,150 --> 00:04:04,730
this,
49

50
00:04:04,750 --> 00:04:09,820
you know, what is their coding style, what are some of the things that they used to create this game.
50

51
00:04:09,880 --> 00:04:12,930
So that was a quick demonstration of git clone.
51

52
00:04:13,240 --> 00:04:21,100
And the other thing that you should realize is that once you've cloned a project and you cd into it,
52

53
00:04:21,220 --> 00:04:23,200
so let's go inside that project,
53

54
00:04:23,200 --> 00:04:29,230
and you can also use git log to check out some of their previous commits, and you can see they've got all
54

55
00:04:29,230 --> 00:04:33,740
these commit messages that tell you what each commit was all about.
55

56
00:04:33,880 --> 00:04:34,180
All right.
56

57
00:04:34,180 --> 00:04:36,180
So that was a little bit on git cloning.
57

58
00:04:36,190 --> 00:04:43,780
So in the future, when you need to grab any of the skeleton project from our GitHub repository,
58

59
00:04:43,810 --> 00:04:45,060
then you'll know what to do,
59

60
00:04:45,080 --> 00:04:50,820
then you'll be able to use git clone to grab it and download it onto your local system.
60

61
00:04:50,830 --> 00:04:55,690
So in the next lesson, I'm going to be talking about something slightly more advanced. I'm gonna be talking
61

62
00:04:55,690 --> 00:05:00,850
about forking, making pull requests, and merging repositories.
62

63
00:05:01,000 --> 00:05:03,110
So all of that is yet to come.
63

64
00:05:03,110 --> 00:05:04,680
So I'll see you on the next lesson.
