0
1
00:00:00,620 --> 00: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

2
00:00:08,180 --> 00:00:09,170
Hub.
2

3
00:00:09,170 --> 00:00:17,140
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,330 --> 00: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

5
00:00:26,360 --> 00:00:33,860
of the commits and all of the versions of a particular remote repository and to store the files inside
5

6
00:00:33,950 --> 00:00:35,690
your working directory.
6

7
00:00:35,690 --> 00:00:38,320
So let's give it a go and see how it works in practice.
7

8
00:00:38,450 --> 00:00:44,360
So inside GitHub if you search for open source iOS apps, you can actually see a collaborative list
8

9
00:00:44,780 --> 00:00:48,060
of really awesome open source iOS apps.
9

10
00:00:48,080 --> 00: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

11
00:00:54,740 --> 00:00:55,300
have made
11

12
00:00:55,330 --> 00:01:03,170
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,230 --> 00:01:08,070
and it's a really really good resource that I would recommend you to bookmark.
13

14
00:01:08,090 --> 00: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

15
00:01:15,380 --> 00:01:17,900
it to our local machine.
15

16
00:01:17,900 --> 00:01:20,170
So this is a really cool repository.
16

17
00:01:20,180 --> 00:01:27,160
This is the game 2048 that this guy Austin Zheng has created.
17

18
00:01:27,350 --> 00: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

19
00:01:35,540 --> 00:01:36,130
a go.
19

20
00:01:36,350 --> 00:01:37,710
So let's try and do that.
20

21
00:01:37,820 --> 00:01:42,740
So the first thing we're going to go to is this button where it says  clone or download.
21

22
00:01:42,770 --> 00:01:49,700
Now previously when we've been asking you to download our skeleton project because we haven't yet covered
22

23
00:01:49,810 --> 00:01:55,220
Git or GitHub, we've always asked you to simply download the zip and unzip it.
23

24
00:01:55,310 --> 00:01:59,260
Now this is not as great an option as using git clone.
24

25
00:01:59,450 --> 00:02:00,530
So that's what we're going to do.
25

26
00:02:00,530 --> 00:02:09,680
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,680 --> 00:02:11,470
it to our desktop.
27

28
00:02:11,660 --> 00: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

29
00:02:20,090 --> 00:02:23,390
and then I'm going to paste that URL that I copied earlier on.
29

30
00:02:23,480 --> 00: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

31
00:02:33,560 --> 00:02:36,680
it didn't even take that long because it's actually quite small.
31

32
00:02:36,710 --> 00:02:40,120
So now if I have a look at my desktop I can see this folder.
32

33
00:02:40,220 --> 00: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

34
00:02:45,680 --> 00:02:52,730
all of the project files inside swift 2048 as well as the swift Xcode project.
34

35
00:02:52,730 --> 00:02:59,390
So let's go ahead and double click it to launch it and let's see if it works.
35

36
00:03:02,760 --> 00: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

37
00:03:08,490 --> 00:03:08,930
things.
37

38
00:03:08,940 --> 00:03:16,500
Now if you wanted to run this or anything that you clone from the from GitHub then you obviously have
38

39
00:03:16,500 --> 00:03:20,610
to change your bundle identifier and also change your team.
39

40
00:03:20,610 --> 00: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

41
00:03:25,020 --> 00:03:27,440
so these things don't matter so much.
41

42
00:03:28,600 --> 00:03:28,860
All right.
42

43
00:03:28,870 --> 00: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

44
00:03:38,170 --> 00:03:41,100
click to rights to swipe right.
44

45
00:03:41,260 --> 00:03:46,050
And you can see that this is a beautiful implementation of the 2048 game.
45

46
00:03:46,180 --> 00:03:48,580
So it works absolutely perfectly
46

47
00:03:48,580 --> 00: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

48
00:03:56,320 --> 00:03:58,490
run it on your phone and play with it.
48

49
00:03:58,660 --> 00:04:04,060
But more importantly you can  have a look inside the code files and see how exactly did they achieve
49

50
00:04:04,090 --> 00:04:04,710
this,
50

51
00:04:04,730 --> 00:04:09,760
you know what is their coding style, what are some of the things that they used to create this game.
51

52
00:04:09,820 --> 00:04:12,980
So that was a quick demonstration of git clone.
52

53
00:04:13,210 --> 00: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

54
00:04:21,160 --> 00:04:23,140
so let's go inside that project.
54

55
00:04:23,170 --> 00: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

56
00:04:29,170 --> 00:04:33,680
these commit messages that tell you what each commit was all about.
56

57
00:04:33,820 --> 00:04:34,110
All right.
57

58
00:04:34,120 --> 00:04:36,150
So that was a little bit on git cloning.
58

59
00:04:36,160 --> 00:04:43,720
So in the future when you need to grab any of the skeleton projects from our GitHub repository then
59

60
00:04:43,750 --> 00:04:44,940
you'll know what to do.
60

61
00:04:44,980 --> 00:04:50,770
Then you'll be able to use git clone to grab it and download it on to your local system.
61

62
00:04:50,770 --> 00: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

63
00:04:55,660 --> 00:05:00,800
about forking, making pull requests and merging repositories.
63

64
00:05:00,940 --> 00:05:03,030
So all of that is yet to come.
64

65
00:05:03,040 --> 00:05:04,370
So I'll see you on the next lesson.
