0
1
00:00:00,810 --> 00:00:01,160
All right.
1

2
00:00:01,170 --> 00:00:08,730
So whereas in the last lesson, we were looking at local implementations of using Git and version control.
2

3
00:00:09,300 --> 00:00:14,910
In this lesson, we're going to talk about how you can create a remote repository, so a repository that's
3

4
00:00:14,910 --> 00:00:20,850
hosted on somebody else's server or somebody else's computer by using GitHub.
4

5
00:00:20,850 --> 00:00:22,770
Now most people would have heard of GitHub,
5

6
00:00:22,800 --> 00:00:28,830
and certainly by now, you would have used GitHub many times in order to grab the skeleton projects that
6

7
00:00:28,830 --> 00:00:32,370
we've provided for some of the tutorials and challenges.
7

8
00:00:32,370 --> 00:00:37,550
So if you haven't yet set up an account on GitHub, then this is the time to do it.
8

9
00:00:37,650 --> 00:00:44,630
So head over to github.com and simply fill out this quick form to create an account on GitHub.
9

10
00:00:44,640 --> 00:00:51,450
So it's completely free and all you need to do is just confirm your email so that you can access it.
10

11
00:00:51,630 --> 00:00:54,110
Once you've done that, go ahead and sign in.
11

12
00:00:54,270 --> 00:00:59,640
So once you've signed in, you should be looking at this page. And what we're going to do is we're going
12

13
00:00:59,640 --> 00:01:04,310
to create a repository inside the browser-based GitHub.
13

14
00:01:04,320 --> 00:01:10,890
So if you navigate to this top right corner and click that plus arrow, then you can select New repository.
14

15
00:01:11,430 --> 00:01:13,490
And I'm going to call my repository
15

16
00:01:13,680 --> 00:01:16,000
same name, I guess we'll call it Story.
16

17
00:01:16,320 --> 00:01:26,330
And let's give it a description, let's say, "My masterpiece." Now, by default, all repositories that you create
17

18
00:01:26,330 --> 00:01:34,390
on GitHub are public. That means that anyone can see all of the files inside your save repository.
18

19
00:01:34,430 --> 00:01:41,670
So everything that you commit to your remote repository or to your GitHub repository will be public.
19

20
00:01:41,750 --> 00:01:48,180
So if you don't want that, then you can select Private which requires a subscription on GitHub.
20

21
00:01:48,350 --> 00:01:53,780
But in most cases, if you're not doing anything that's top secret or if you're not developing technology
21

22
00:01:53,780 --> 00:02:00,470
that is completely brand new, then having a public repository is not such a big problem.
22

23
00:02:00,710 --> 00:02:06,590
And on the other hand as well, you can see loads of other people's public repository, and you can see,
23

24
00:02:06,590 --> 00:02:08,980
for example, how they structure their code,
24

25
00:02:09,050 --> 00:02:10,720
what is their style,
25

26
00:02:10,940 --> 00:02:12,820
and you can see how people do things.
26

27
00:02:12,950 --> 00:02:19,660
So, for example, on GitHub, there are whole repositories on things like Swift Flappy Bird.
27

28
00:02:20,000 --> 00:02:27,770
So it's the entire implementation of Flappy Bird in Swift and you can run it in a simulator
28

29
00:02:27,780 --> 00:02:35,260
or you can also look through their code base to see how they did this. So this is the beauty of open-source
29

30
00:02:35,260 --> 00:02:35,830
code.
30

31
00:02:35,890 --> 00:02:43,330
And as you develop in your journey of becoming a developer, then you might find that you want to contribute
31

32
00:02:43,420 --> 00:02:45,370
to other open-source projects,
32

33
00:02:45,490 --> 00:02:51,400
help them out a bit, and work in a virtual team to try and contribute your knowledge and your programming
33

34
00:02:51,400 --> 00:02:52,200
skills.
34

35
00:02:52,540 --> 00:02:58,920
Okay. So, now once I've selected public, the next thing is that I'm going to leave this part empty.
35

36
00:02:59,020 --> 00:03:03,400
I'm not going to initialize a README from my repository just yet.
36

37
00:03:03,400 --> 00:03:09,240
So the next thing is that I'm going to go ahead and click the big green button and create my repository.
37

38
00:03:09,700 --> 00:03:16,210
So, now you can see that there are two ways that they tell you you can set up your repository.
38

39
00:03:16,420 --> 00:03:23,890
You can either set it up in a GitHub for Mac on desktop, their desktop client, which I am not a big fan
39

40
00:03:23,890 --> 00:03:29,980
of, but instead, what we're going to do is we're going to use the command line instructions to set up
40

41
00:03:30,020 --> 00:03:31,300
our repository.
41

42
00:03:31,300 --> 00:03:38,920
So, we are going to push an existing repository that we've got locally onto this remote repository. 
42

43
00:03:38,920 --> 00:03:47,770
And to do that, we need to copy the address of out GitHub repository and we're going to use these two lines
43

44
00:03:47,770 --> 00:03:54,790
of code in order to transfer or push our existing local repository from the command line.
44

45
00:03:54,790 --> 00:03:55,060
All right.
45

46
00:03:55,060 --> 00:04:01,810
So I'm currently inside my Story directory which also happens to be the working directory for this particular
46

47
00:04:01,810 --> 00:04:02,590
project.
47

48
00:04:02,920 --> 00:04:10,510
And here, I am going to, again, take a look at git log to see what previous commits we've got,
48

49
00:04:10,660 --> 00:04:13,010
and you can see that we've got two previous commits.
49

50
00:04:13,120 --> 00:04:17,670
And I would like to push both of these commits onto GitHub.
50

51
00:04:18,130 --> 00:04:26,110
So to do that, the first thing is creating a remote. So it's telling my local git repository that I've
51

52
00:04:26,110 --> 00:04:31,090
created a remote repository somewhere on the Internet
52

53
00:04:31,360 --> 00:04:35,560
and I want to transfer all of my commits over there.
53

54
00:04:35,740 --> 00:04:43,930
So the command that we're going to use is "git remote add origin." Now origin is simply the name of your
54

55
00:04:43,980 --> 00:04:48,110
remote and you can theoretically call it anything you want.
55

56
00:04:48,190 --> 00:04:50,460
You can call it bacon if you want.
56

57
00:04:50,770 --> 00:04:57,940
But by convention, and it's highly recommended that you simply keep the name origin, and the reason is
57

58
00:04:57,940 --> 00:05:04,900
because most programmers are used to the conventional naming and that means it'll be much easier for
58

59
00:05:04,900 --> 00:05:09,640
them to understand what's going on in your projects when they have a look at it, instead of you doing
59

60
00:05:09,640 --> 00:05:14,560
something completely different which will be very surprising and it'll be a lot harder for people to
60

61
00:05:14,560 --> 00:05:16,120
understand what's going on.
61

62
00:05:16,420 --> 00:05:24,820
So git remote add origin and then we're going to paste the URL of our remote repository on GitHub,
62

63
00:05:24,820 --> 00:05:27,880
and then we're going to go ahead and hit enter.
63

64
00:05:28,660 --> 00:05:36,820
And now that remote is created, so we can push our local repository onto our remote repository which
64

65
00:05:36,820 --> 00:05:38,210
is called origin.
65

66
00:05:38,350 --> 00:05:44,980
So we're going to say "git push -u origin master."
66

67
00:05:45,280 --> 00:05:52,900
And what this line of code does is that it pushes your local repository to the remote repository using
67

68
00:05:52,900 --> 00:06:00,640
the -u flag or the -u option which basically links up your remote and your local repositories.
68

69
00:06:00,700 --> 00:06:06,220
And then we're going to push it towards the remote that's called origin and we're going to push it to the
69

70
00:06:06,220 --> 00:06:08,690
branch that's called master.
70

71
00:06:08,710 --> 00:06:15,470
So the master branch is simply the default branch or the main branch of all of your commits.
71

72
00:06:15,580 --> 00:06:21,400
And later on when we cover branching, then we're going to talk more about what is a master and what is
72

73
00:06:21,400 --> 00:06:22,200
a branch.
73

74
00:06:22,220 --> 00:06:28,810
But for now which is saying that we're going to push a local repository onto this origin remote and
74

75
00:06:28,840 --> 00:06:30,860
we're going to push it to the master branch.
75

76
00:06:30,940 --> 00:06:33,210
So let's go ahead and hit enter.
76

77
00:06:34,090 --> 00:06:38,740
And there's going to be a little bit of work being done in the background because it's actually going
77

78
00:06:38,740 --> 00:06:46,510
to have to upload your local repository to the remote repository on GitHub servers. And depending on
78

79
00:06:46,510 --> 00:06:52,380
the size of your local repository, this can take various amounts of time.
79

80
00:06:52,390 --> 00:06:54,650
So, now once we see our prompt,
80

81
00:06:54,670 --> 00:07:00,210
so the flashing cursor or the dollar sign, that means our push is successful.
81

82
00:07:00,520 --> 00:07:06,400
And as you can see, it says, "Branch master set up to track remote branch master from origin."
82

83
00:07:06,430 --> 00:07:12,730
Sounds really confusing. But if you head back over to GitHub and if you're on the same page, all you
83

84
00:07:12,730 --> 00:07:19,900
have to do is hit command R to refresh or just press the refresh button, and you can see that all of our
84

85
00:07:19,900 --> 00:07:27,450
files are now hosted on GitHub and it's complete with all of our commit messages.
85

86
00:07:27,460 --> 00:07:35,330
So if you go on to Insights, Graphs, and go into Network, you can actually see our master branch which
86

87
00:07:35,330 --> 00:07:39,090
currently only has two save points or two commits.
87

88
00:07:39,090 --> 00:07:43,680
And if you hover over them, you can actually see the commit messages of each of these.
88

89
00:07:43,700 --> 00:07:50,780
So as you build out your project, as you add more commits, either locally or pushing it remotely, or probably
89

90
00:07:50,780 --> 00:07:56,840
doing both, then you can see the progress of your files in your GitHub repository.
90

91
00:07:56,930 --> 00:08:05,180
So, now you can see all of the code if it's code file, or in our case, it's just a text file hosted on
91

92
00:08:05,250 --> 00:08:08,570
GitHub, and you can point anybody towards this.
92

93
00:08:08,630 --> 00:08:15,260
And there are actually cases where people do a lot of story writing using GitHub just because it's so
93

94
00:08:15,260 --> 00:08:22,160
good at tracking, you'll save points, and being able to revert to previous versions in the past.
94

95
00:08:22,160 --> 00:08:30,410
So for example, if you head back to the main page and you go to your commits, you can see both of those
95

96
00:08:30,420 --> 00:08:32,590
commits when they were committed.
96

97
00:08:32,720 --> 00:08:38,600
And also if you click on it, you can see the version, you can see the changes that were made at those
97

98
00:08:38,600 --> 00:08:39,270
time points.
98

99
00:08:39,320 --> 00:08:45,530
So if we have a look at Chapter 1, you can see this is all we had at the point when we made our first
99

100
00:08:45,530 --> 00:08:46,310
commit.
100

101
00:08:46,310 --> 00:08:52,370
So, previously, we said that we have a working directory which is the directory where we initialized git,
101

102
00:08:52,610 --> 00:08:58,440
then we can push off files to a staging area where we can pick and choose which files we want to commit.
102

103
00:08:58,580 --> 00:09:06,360
Then once we're ready, then we can commit our files or our save point to our local repository.
103

104
00:09:06,620 --> 00:09:13,160
So once you've done a few commits, then you actually have this timeline of various commits.
104

105
00:09:13,370 --> 00:09:16,600
And this is called your master branch.
105

106
00:09:16,670 --> 00:09:23,870
So the master branch is your main branch of commits or save points, and it is sequential.
106

107
00:09:23,870 --> 00:09:29,840
And this is usually where your main progress is saved or committed.
107

108
00:09:29,840 --> 00:09:36,300
Now, later on, we then introduced this idea of the remote repository.
108

109
00:09:36,320 --> 00:09:42,260
The important thing to note is that you can have a local repository completely in parallel with a remote
109

110
00:09:42,260 --> 00:09:43,090
repository.
110

111
00:09:43,160 --> 00:09:48,630
Check the differences between them but you can also sync them so that they are the same.
111

112
00:09:49,160 --> 00:09:54,600
But you can also sync them or push things from your local repository to your remote repository.
112

113
00:09:54,620 --> 00:10:02,360
So in our case, the local repository is the Git file that we've got inside our Story directory. And the
113

114
00:10:02,360 --> 00:10:10,490
remote repository is the Git directory that we've got inside our Story directory. And the remote repository
114

115
00:10:10,640 --> 00:10:17,810
is GitHub which hosts our code and also hosts all of the changes that were made in between the different
115

116
00:10:17,810 --> 00:10:18,360
commits.
116

117
00:10:18,380 --> 00:10:24,710
So we have this master branch of various commits, first commit, second commit, third commit in our local
117

118
00:10:24,740 --> 00:10:32,780
Git repository. And when we performed the command git push, then that effectively pushed all of those
118

119
00:10:32,840 --> 00:10:42,340
commits, all of those various versions and changes, and code pieces to our remote repository on GitHub.
119

120
00:10:42,350 --> 00:10:45,100
So that's what Git pushed us. Now in the next lesson,
120

121
00:10:45,110 --> 00:10:50,690
I want to talk about using "gitignore" and how you can avoid uploading sensitive pieces of information
121

122
00:10:50,960 --> 00:10:56,750
such as API keys or passwords to your remote repositories, for example, GitHub.
122

123
00:10:56,810 --> 00:10:59,340
So all of that and more on the next lesson,
123

124
00:10:59,360 --> 00:10:59,900
see you there.
