1
00:00:00,690 --> 00:00:03,120
Instructor: All right, so whereas in the last lesson,

2
00:00:03,120 --> 00:00:05,910
we were looking at local implementations

3
00:00:05,910 --> 00:00:09,150
of using Git and version control.

4
00:00:09,150 --> 00:00:11,730
In this lesson, we're gonna talk about how you can create

5
00:00:11,730 --> 00:00:13,680
a remote repository,

6
00:00:13,680 --> 00:00:16,890
so a repository that's hosted on somebody else's server

7
00:00:16,890 --> 00:00:20,760
or somebody else's computer by using GitHub.

8
00:00:20,760 --> 00:00:22,680
Now most people would have heard of GitHub

9
00:00:22,680 --> 00:00:26,610
and certainly by now, you would have used GitHub many times.

10
00:00:26,610 --> 00:00:29,850
So if you haven't yet set up an account on GitHub,

11
00:00:29,850 --> 00:00:31,890
then this is the time to do it.

12
00:00:31,890 --> 00:00:33,870
So head over to github.com

13
00:00:33,870 --> 00:00:36,480
and simply fill out this quick form

14
00:00:36,480 --> 00:00:38,910
to create an account on GitHub.

15
00:00:38,910 --> 00:00:40,380
It's completely free

16
00:00:40,380 --> 00:00:43,380
and all you need to do is just confirm your email

17
00:00:43,380 --> 00:00:44,680
so that you can access it.

18
00:00:45,690 --> 00:00:48,420
Once you've done that, go ahead and sign in.

19
00:00:48,420 --> 00:00:51,690
Once you've signed in, you should be looking at this page.

20
00:00:51,690 --> 00:00:52,740
And what we're gonna do

21
00:00:52,740 --> 00:00:55,590
is we're going to create a repository

22
00:00:55,590 --> 00:00:58,020
inside the browser-based GitHub.

23
00:00:58,020 --> 00:01:00,150
So if you navigate to this top right corner

24
00:01:00,150 --> 00:01:02,280
and click that plus arrow,

25
00:01:02,280 --> 00:01:05,129
then you can select new repository.

26
00:01:05,129 --> 00:01:08,040
And I'm gonna call my repository same name,

27
00:01:08,040 --> 00:01:09,990
I guess we'll call it Story.

28
00:01:09,990 --> 00:01:11,790
And let's give it a description.

29
00:01:11,790 --> 00:01:15,873
Let's say my masterpiece.

30
00:01:17,100 --> 00:01:18,480
Now by default,

31
00:01:18,480 --> 00:01:22,020
all repositories that you create on GitHub are public.

32
00:01:22,020 --> 00:01:24,930
That means that anyone can see all of the files

33
00:01:24,930 --> 00:01:28,020
inside your save repository.

34
00:01:28,020 --> 00:01:31,080
Everything that you commit to your remote repository

35
00:01:31,080 --> 00:01:35,070
or to your GitHub repository will be public.

36
00:01:35,070 --> 00:01:38,730
If you don't want that, then you can select private.

37
00:01:38,730 --> 00:01:40,080
But in most cases,

38
00:01:40,080 --> 00:01:42,480
if you're not doing anything that's top secret

39
00:01:42,480 --> 00:01:44,130
or if you're not developing technology

40
00:01:44,130 --> 00:01:46,710
that is completely brand new,

41
00:01:46,710 --> 00:01:51,030
then having a public repository is not such a big problem.

42
00:01:51,030 --> 00:01:52,830
And on the other hand as well

43
00:01:52,830 --> 00:01:56,160
you can see loads of other people's public repository

44
00:01:56,160 --> 00:01:59,370
and you can see for example how they structure their code,

45
00:01:59,370 --> 00:02:02,880
what is their style and you can see how people do things.

46
00:02:02,880 --> 00:02:05,460
For example on GitHub, there are whole repositories

47
00:02:05,460 --> 00:02:08,460
on things like Flappy Bird.

48
00:02:08,460 --> 00:02:13,170
So it's the entire implementation of a Flappy Bird

49
00:02:13,170 --> 00:02:15,450
and you can run it or you can also

50
00:02:15,450 --> 00:02:18,603
look through their code base to see how they did this.

51
00:02:19,710 --> 00:02:22,050
This is the beauty of open source code.

52
00:02:22,050 --> 00:02:26,130
And as you develop in your journey of becoming a developer,

53
00:02:26,130 --> 00:02:29,160
then you might find that you want to contribute

54
00:02:29,160 --> 00:02:31,200
to other open source projects.

55
00:02:31,200 --> 00:02:34,110
Help them out a bit and work in a virtual team

56
00:02:34,110 --> 00:02:36,300
to try and contribute your knowledge

57
00:02:36,300 --> 00:02:38,250
and your programming skills.

58
00:02:38,250 --> 00:02:40,560
Okay so, once I've selected public,

59
00:02:40,560 --> 00:02:44,160
the next thing is that I'm gonna leave this part empty.

60
00:02:44,160 --> 00:02:46,410
I'm not going to initialize a read me

61
00:02:46,410 --> 00:02:48,570
for my repository just yet.

62
00:02:48,570 --> 00:02:50,100
The next thing is that I'm gonna go ahead

63
00:02:50,100 --> 00:02:54,540
and click the big green button and create my repository.

64
00:02:54,540 --> 00:02:58,050
Now you can see that there are two ways that they tell you

65
00:02:58,050 --> 00:03:00,900
you can set up your repository.

66
00:03:00,900 --> 00:03:04,530
You can either set it up in GitHub on desktop,

67
00:03:04,530 --> 00:03:07,830
their desktop client, which I am not a big fan of.

68
00:03:07,830 --> 00:03:09,660
But instead, what we're gonna do

69
00:03:09,660 --> 00:03:12,750
is we're gonna use the command line instructions

70
00:03:12,750 --> 00:03:14,880
to set up our repository.

71
00:03:14,880 --> 00:03:18,030
So we are going to push an existing repository

72
00:03:18,030 --> 00:03:19,770
that we've got locally

73
00:03:19,770 --> 00:03:22,380
onto this remote repository.

74
00:03:22,380 --> 00:03:23,460
And to do that,

75
00:03:23,460 --> 00:03:28,460
we need to copy the address of our GitHub repository

76
00:03:28,710 --> 00:03:31,440
and we're going to use these two lines of code

77
00:03:31,440 --> 00:03:36,440
in order to transfer or push our existing local repository

78
00:03:36,600 --> 00:03:38,040
from the command line.

79
00:03:38,040 --> 00:03:41,580
All right, I'm currently inside my story directory

80
00:03:41,580 --> 00:03:43,830
which also happens to be the working directory

81
00:03:43,830 --> 00:03:45,780
for this particular project.

82
00:03:45,780 --> 00:03:50,780
And here, I am going to again take a look at Git log

83
00:03:51,330 --> 00:03:53,520
to see what previous commits we've got.

84
00:03:53,520 --> 00:03:55,950
And you can see that we've got two previous commits.

85
00:03:55,950 --> 00:03:59,763
And I would like to push both of these commits onto GitHub.

86
00:04:00,930 --> 00:04:01,890
To do that,

87
00:04:01,890 --> 00:04:05,010
the first thing is creating a remote.

88
00:04:05,010 --> 00:04:08,130
So it's telling my local Git repository

89
00:04:08,130 --> 00:04:12,300
that I've created a remote repository

90
00:04:12,300 --> 00:04:13,830
somewhere on the internet

91
00:04:13,830 --> 00:04:18,240
and I want to transfer all of my commits over there.

92
00:04:18,240 --> 00:04:19,680
So the command that we're gonna use

93
00:04:19,680 --> 00:04:23,550
is git remote add origin.

94
00:04:23,550 --> 00:04:27,060
Now origin is simply the name of your remote

95
00:04:27,060 --> 00:04:30,690
and you can theoretically call it anything you want.

96
00:04:30,690 --> 00:04:32,850
You can call it bacon if you want

97
00:04:32,850 --> 00:04:36,630
but by convention and it's highly recommended

98
00:04:36,630 --> 00:04:39,240
that you simply keep the name origin.

99
00:04:39,240 --> 00:04:42,480
And the reason is because most programmers are used

100
00:04:42,480 --> 00:04:45,060
to the conventional naming

101
00:04:45,060 --> 00:04:47,820
and that means it'll be much easier for them to understand

102
00:04:47,820 --> 00:04:49,710
what's going on in your project

103
00:04:49,710 --> 00:04:50,850
when they have a look at it

104
00:04:50,850 --> 00:04:53,100
instead of you doing something completely different

105
00:04:53,100 --> 00:04:54,750
which will be very surprising

106
00:04:54,750 --> 00:04:57,120
and it'll be a lot harder for people to understand

107
00:04:57,120 --> 00:04:58,470
what's going on.

108
00:04:58,470 --> 00:05:00,720
So git remote add origin

109
00:05:00,720 --> 00:05:04,560
and then we're going to paste the URL

110
00:05:04,560 --> 00:05:07,620
of our remote repository on GitHub

111
00:05:07,620 --> 00:05:10,650
and then we're gonna go ahead and hit Enter.

112
00:05:10,650 --> 00:05:13,320
And now that remote is created.

113
00:05:13,320 --> 00:05:16,200
So we can push our local repository

114
00:05:16,200 --> 00:05:20,340
onto our remote repository which is called origin.

115
00:05:20,340 --> 00:05:25,340
So we're gonna say git push -u origin main.

116
00:05:26,460 --> 00:05:28,290
And what this line of code does

117
00:05:28,290 --> 00:05:31,590
is that it pushes your local repository

118
00:05:31,590 --> 00:05:33,600
to the remote repository

119
00:05:33,600 --> 00:05:36,930
using the U flag or the U option

120
00:05:36,930 --> 00:05:39,270
which basically links up your remote

121
00:05:39,270 --> 00:05:41,250
and your local repositories.

122
00:05:41,250 --> 00:05:44,580
And then we're going to push it towards the remote

123
00:05:44,580 --> 00:05:46,230
that's called origin.

124
00:05:46,230 --> 00:05:49,320
And we're going to push it to the branch that's called main.

125
00:05:49,320 --> 00:05:52,200
The main branch is simply the default branch

126
00:05:52,200 --> 00:05:55,470
or the main branch of all of your commits.

127
00:05:55,470 --> 00:05:58,410
And later on when we cover branching,

128
00:05:58,410 --> 00:06:00,690
then we're gonna talk more about what is a main

129
00:06:00,690 --> 00:06:01,920
and what is a branch.

130
00:06:01,920 --> 00:06:02,753
But for now,

131
00:06:02,753 --> 00:06:04,140
we're just saying that we're going to push

132
00:06:04,140 --> 00:06:08,250
our local repository onto this origin remote

133
00:06:08,250 --> 00:06:10,470
and we're going to push it to the main branch.

134
00:06:10,470 --> 00:06:12,363
So let's go ahead and hit Enter.

135
00:06:13,650 --> 00:06:16,320
And there's gonna be a little bit of work being done

136
00:06:16,320 --> 00:06:17,340
in the background

137
00:06:17,340 --> 00:06:19,860
because it's actually going to have to upload

138
00:06:19,860 --> 00:06:23,400
your local repository to the remote repository

139
00:06:23,400 --> 00:06:25,020
on GitHub servers.

140
00:06:25,020 --> 00:06:28,260
And depending on the size of your local repository,

141
00:06:28,260 --> 00:06:30,633
this can take various amounts of time.

142
00:06:31,680 --> 00:06:34,890
Now once we see our prompt, so the flashing cursor

143
00:06:34,890 --> 00:06:36,360
or the dollar sign,

144
00:06:36,360 --> 00:06:39,480
that means that our push is successful.

145
00:06:39,480 --> 00:06:41,430
And as you can see it says

146
00:06:41,430 --> 00:06:43,320
Branch main set up to track remote

147
00:06:43,320 --> 00:06:44,850
branch main from origin.

148
00:06:44,850 --> 00:06:45,900
Sounds really confusing.

149
00:06:45,900 --> 00:06:48,750
But if you head back over to GitHub

150
00:06:48,750 --> 00:06:50,940
and if you're on the same page,

151
00:06:50,940 --> 00:06:53,490
all you have to do is hit Command+R to refresh

152
00:06:53,490 --> 00:06:56,040
or just press the Refresh button.

153
00:06:56,040 --> 00:06:58,920
And you can see that all of our files

154
00:06:58,920 --> 00:07:01,710
are now hosted on GitHub

155
00:07:01,710 --> 00:07:05,850
and it's complete with all of our commit messages.

156
00:07:05,850 --> 00:07:10,110
So if you go into Insights and go into Network,

157
00:07:10,110 --> 00:07:12,450
you can actually see our main branch

158
00:07:12,450 --> 00:07:16,257
which currently only has two savepoints or two commits.

159
00:07:16,257 --> 00:07:17,550
And if you hover over them,

160
00:07:17,550 --> 00:07:21,060
you can actually see the commit messages of each of these.

161
00:07:21,060 --> 00:07:22,530
As you build out your project,

162
00:07:22,530 --> 00:07:24,360
as you add more commits,

163
00:07:24,360 --> 00:07:28,920
either locally or pushing it remotely or probably doing both

164
00:07:28,920 --> 00:07:31,980
then you can see the progress of your files

165
00:07:31,980 --> 00:07:33,990
in your GitHub repository.

166
00:07:33,990 --> 00:07:38,280
So now, you can see all of the code if it's code file

167
00:07:38,280 --> 00:07:40,620
or in our case it's just a text file,

168
00:07:40,620 --> 00:07:42,870
hosted on GitHub.

169
00:07:42,870 --> 00:07:45,270
And you can point anybody towards this.

170
00:07:45,270 --> 00:07:47,160
And there are actually cases

171
00:07:47,160 --> 00:07:50,520
where people do a lot of story writing using GitHub

172
00:07:50,520 --> 00:07:54,570
just because it's so good at tracking your savepoints

173
00:07:54,570 --> 00:07:57,930
and being able to revert to previous versions in the past.

174
00:07:57,930 --> 00:08:01,440
So for example, if you head over back to the main page

175
00:08:01,440 --> 00:08:04,950
and you go to your commits,

176
00:08:04,950 --> 00:08:08,520
you can see both of those commits, when they were committed.

177
00:08:08,520 --> 00:08:10,080
And also if you click on it,

178
00:08:10,080 --> 00:08:13,650
you can see the changes that were made at those time points.

179
00:08:13,650 --> 00:08:15,720
So if we have a look at chapter one,

180
00:08:15,720 --> 00:08:18,000
you can see this is all we had

181
00:08:18,000 --> 00:08:21,180
at the point when we made our first commit.

182
00:08:21,180 --> 00:08:24,060
Previously, we said that we have a working directory

183
00:08:24,060 --> 00:08:27,120
which is the directory where we initialized Git.

184
00:08:27,120 --> 00:08:29,670
Then we can push our files to a staging area

185
00:08:29,670 --> 00:08:33,090
where we can pick and choose which files we want to commit.

186
00:08:33,090 --> 00:08:36,780
Then once we're ready, then we can commit our files

187
00:08:36,780 --> 00:08:40,830
or our savepoint to our local repository.

188
00:08:40,830 --> 00:08:43,080
So once you've done a few commits,

189
00:08:43,080 --> 00:08:47,610
then you actually have this timeline of various commits

190
00:08:47,610 --> 00:08:50,610
and this is called your main branch.

191
00:08:50,610 --> 00:08:54,120
So the main branch is your main branch of commits

192
00:08:54,120 --> 00:08:55,440
or savepoints

193
00:08:55,440 --> 00:08:57,600
and it is sequential.

194
00:08:57,600 --> 00:09:00,960
And this is usually where your main progress

195
00:09:00,960 --> 00:09:03,600
is saved or committed.

196
00:09:03,600 --> 00:09:06,960
Later on, we then introduced this idea

197
00:09:06,960 --> 00:09:09,510
of the remote repository.

198
00:09:09,510 --> 00:09:11,460
The important thing to note is that

199
00:09:11,460 --> 00:09:14,940
you can have a local repository completely in parallel

200
00:09:14,940 --> 00:09:16,350
with a remote repository,

201
00:09:16,350 --> 00:09:18,300
check the differences between them

202
00:09:18,300 --> 00:09:20,820
but you can also sync them or push things

203
00:09:20,820 --> 00:09:23,760
from your local repository to your remote repository.

204
00:09:23,760 --> 00:09:27,180
So in our case, the local repository is the Git file

205
00:09:27,180 --> 00:09:30,750
that we've got inside our story directory.

206
00:09:30,750 --> 00:09:33,600
And the remote repository is GitHub

207
00:09:33,600 --> 00:09:37,710
which hosts our code and also hosts all of the changes

208
00:09:37,710 --> 00:09:40,320
that were made in between the different commits.

209
00:09:40,320 --> 00:09:43,140
So we have this main branch of various commits:

210
00:09:43,140 --> 00:09:45,390
first commit, second commit, third commit

211
00:09:45,390 --> 00:09:47,940
in our local Git repository.

212
00:09:47,940 --> 00:09:51,570
And when we performed the command git to push,

213
00:09:51,570 --> 00:09:55,650
then that effectively pushed all of those commits,

214
00:09:55,650 --> 00:10:00,650
all of those various versions and changes and code pieces

215
00:10:00,900 --> 00:10:04,110
to our remote repository on GitHub.

216
00:10:04,110 --> 00:10:05,790
So that's what git push does.

217
00:10:05,790 --> 00:10:09,060
Now in the next lesson, I wanna talk about using gitignore

218
00:10:09,060 --> 00:10:10,680
and how you can avoid uploading

219
00:10:10,680 --> 00:10:14,220
sensitive pieces of information such as API keys

220
00:10:14,220 --> 00:10:17,340
or passwords to your remote repositories,

221
00:10:17,340 --> 00:10:18,600
for example, GitHub.

222
00:10:18,600 --> 00:10:21,120
So all of that and more on the next lesson.

223
00:10:21,120 --> 00:10:21,953
See you there.

