1
00:00:00,660 --> 00:00:08,130
All right, so whereas in the last lesson we were looking at local implementations of using Git and version

2
00:00:08,130 --> 00:00:14,640
control, in this lesson we're going to talk about how you can create a remote repository, so a repository

3
00:00:14,640 --> 00:00:20,220
that's hosted on somebody else's server or somebody else's computer by using GitHub.

4
00:00:20,730 --> 00:00:22,710
Now, most people would have heard of GitHub.

5
00:00:23,100 --> 00:00:27,980
So if you haven't yet set up an account on GitHub, then this is the time to do it.

6
00:00:28,350 --> 00:00:35,010
So head over to github.com and simply fill out this quick form to create an account on GitHub.

7
00:00:35,370 --> 00:00:36,780
So it's completely free,

8
00:00:36,990 --> 00:00:41,220
and all you need to do is just confirm your email so that you can access it.

9
00:00:42,360 --> 00:00:44,740
Once you've done that, go ahead and sign in.

10
00:00:45,030 --> 00:00:48,360
So once you've signed it, you should be looking at this page.

11
00:00:48,690 --> 00:00:54,720
And what we're going to do is we're going to create a repository inside the browser-based GitHub.

12
00:00:55,050 --> 00:01:01,370
So if you navigate to this top-right corner and click that plus arrow, then you can select new repository.

13
00:01:02,100 --> 00:01:06,510
And I'm going to call my repository same name, I guess we'll call it story.

14
00:01:06,990 --> 00:01:08,820
And let's give it a description.

15
00:01:08,820 --> 00:01:12,750
Let's say my masterpiece.

16
00:01:14,160 --> 00:01:20,370
Now, by default, all repositories that you create on GitHub are public, that means that anyone can

17
00:01:20,370 --> 00:01:24,860
see all of the files inside your saved repository.

18
00:01:25,170 --> 00:01:31,780
So everything that you commit to your remote repository or to your GitHub repository will be public.

19
00:01:32,490 --> 00:01:38,730
So if you don't want that, then you can select private, which requires a subscription on GitHub.

20
00:01:39,090 --> 00:01:44,550
But in most cases, if you're not doing anything that's top-secret or if you're not developing technology

21
00:01:44,550 --> 00:01:51,010
that is completely brand new, then having a public repository is not such a big problem.

22
00:01:51,360 --> 00:01:57,120
And on the other hand, as well, you can see loads of other people's public repositories and you can

23
00:01:57,120 --> 00:02:02,850
see, for example, how they structure their code, what is their style, and you can see how people

24
00:02:02,850 --> 00:02:03,460
do things.

25
00:02:03,600 --> 00:02:06,090
So this is the beauty of open source code.

26
00:02:06,270 --> 00:02:13,860
And as you develop in your journey of becoming a developer, then you might find that you want to contribute

27
00:02:13,860 --> 00:02:19,980
to other open-source projects, help them out a bit, and work in a virtual team to try and contribute

28
00:02:19,980 --> 00:02:22,320
your knowledge and your programming skills.

29
00:02:22,950 --> 00:02:29,060
OK, so now once I've selected public, the next thing is that I'm going to leave this part empty.

30
00:02:29,430 --> 00:02:33,190
I'm not going to initialize a README for my repository just yet.

31
00:02:33,810 --> 00:02:39,240
So the next thing is that I'm going to go ahead and click the big green button and create my repository.

32
00:02:40,140 --> 00:02:44,010
So now you can see that there are two ways that they tell you

33
00:02:44,010 --> 00:02:51,780
you can set up your repository. You can either set it up in GitHub on desktop, their desktop client,

34
00:02:52,110 --> 00:02:53,580
which I am not a big fan of.

35
00:02:53,580 --> 00:02:59,580
But instead, what we're going to do is we're going to use the command-line instructions to set up our

36
00:02:59,580 --> 00:03:00,320
repository.

37
00:03:00,660 --> 00:03:07,950
So we are going to push an existing repository that we've got locally onto this remote repository.

38
00:03:08,100 --> 00:03:14,400
And to do that, we need to copy the address of our Github repository.

39
00:03:14,970 --> 00:03:22,710
And we're going to use these two lines of code in order to transfer or push our existing local repository

40
00:03:22,950 --> 00:03:23,910
from the command line.

41
00:03:24,150 --> 00:03:24,490
All right.

42
00:03:24,490 --> 00:03:30,780
So I'm currently inside my story directory, which also happens to be the working directory for this

43
00:03:30,780 --> 00:03:31,740
particular project.

44
00:03:32,230 --> 00:03:39,780
And here, I am going to again take a look at git log to see what previous commits we've got.

45
00:03:40,050 --> 00:03:42,210
And you can see that we've got two previous commits.

46
00:03:42,450 --> 00:03:46,560
And I would like to push both of these committees onto GitHub.

47
00:03:47,520 --> 00:03:51,690
So to do that, the first thing is creating a remote.

48
00:03:51,990 --> 00:04:00,390
So it's telling my local git repository that I've created a remote repository somewhere on the Internet

49
00:04:00,690 --> 00:04:04,910
and I want to transfer all of my commits over there.

50
00:04:05,130 --> 00:04:10,000
So the command that we're going to use is git remote add origin.

51
00:04:10,440 --> 00:04:17,340
Now, origin is simply the name of your remote and you can theoretically call it anything you want.

52
00:04:17,580 --> 00:04:25,290
You can call it bacon if you want, but by convention and it's highly recommended that you simply keep

53
00:04:25,290 --> 00:04:26,280
the name origin.

54
00:04:26,520 --> 00:04:33,270
And the reason is because most programmers are used to the conventional naming, and that means it'll

55
00:04:33,270 --> 00:04:38,130
be much easier for them to understand what's going on in your project when they have a look at it,

56
00:04:38,220 --> 00:04:42,660
instead of you doing something completely different which will be very surprising and will be a lot

57
00:04:42,660 --> 00:04:45,200
harder for people to understand what's going on.

58
00:04:45,810 --> 00:04:54,570
So git remote add origin, and then we're going to paste the URL of our remote repository on GitHub

59
00:04:54,930 --> 00:04:56,700
and then we're going to go ahead and hit enter.

60
00:04:57,990 --> 00:05:06,270
And now that remote is created so we can push our local repository onto our remote repository, which

61
00:05:06,270 --> 00:05:07,280
is called origin.

62
00:05:07,710 --> 00:05:14,180
So we're going to say git push -u origin master.

63
00:05:14,610 --> 00:05:22,320
And what this line of code does is that it pushes your local repository to the remote repository using

64
00:05:22,320 --> 00:05:29,010
the -u flag or the u option which basically links up your remote and your local repositories.

65
00:05:29,520 --> 00:05:35,430
And then we're going to push it towards the remote that's called origin, and we're going to push it

66
00:05:35,430 --> 00:05:37,550
to the branch that's called master.

67
00:05:38,070 --> 00:05:44,790
So the master branch is simply the default branch or the main branch of all of your commits.

68
00:05:44,970 --> 00:05:51,570
So let's go ahead and hit enter, and there's going to be a little bit of work being done in the background

69
00:05:51,780 --> 00:05:58,860
because it's actually going to have to upload your local repository to the remote repository on GitHub

70
00:05:58,860 --> 00:05:59,430
servers.

71
00:05:59,730 --> 00:06:05,190
And depending on the size of your local repository, this can take various amounts of time.

72
00:06:06,420 --> 00:06:13,410
So now once we see our prompt, so the flashing cursor or the dollar sign, that means our push is 

73
00:06:13,470 --> 00:06:20,210
successful and as you can see, it says branch master set up to track remote branch master from origin,

74
00:06:20,430 --> 00:06:26,820
sounds really confusing, but if you head back over to GitHub and if you're on the same page, all you

75
00:06:26,820 --> 00:06:31,080
have to do is hit command+r to refresh or just press the refresh button.

76
00:06:31,620 --> 00:06:41,000
And you can see that all of our files are now hosted on GitHub and it's complete with all of our commit messages.

77
00:06:41,460 --> 00:06:49,410
So if you go into insights, graphs, and go into network, you can actually see our master branch, which

78
00:06:49,410 --> 00:06:52,830
currently only has two save points or two commits.

79
00:06:53,190 --> 00:06:57,300
And if you hover over them, you can actually see the messages of each of these.

80
00:06:57,750 --> 00:07:04,080
So as you build out your project, as you add more commits either locally or pushing it remotely

81
00:07:04,110 --> 00:07:10,830
or probably doing both, then you can see the progress of your files in your GitHub repository.

82
00:07:10,950 --> 00:07:14,250
So now you can see all of the code

83
00:07:14,250 --> 00:07:19,830
if it's a code file or in our case, it's just a text file hosted on GitHub.

84
00:07:20,190 --> 00:07:22,620
And you can point anybody towards this.

85
00:07:22,620 --> 00:07:28,950
And there are actually cases where people do a lot of story writing using GitHub just because it's

86
00:07:28,950 --> 00:07:35,910
so good at tracking your save points and being able to revert to previous versions in the past.

87
00:07:36,210 --> 00:07:44,190
So, for example, if you head over back to the main page and you go to your commits, you can see both

88
00:07:44,190 --> 00:07:46,500
of those commits, when they were committed,

89
00:07:46,710 --> 00:07:51,810
and also, if you click on it, you can see the changes that were made at those time points.

90
00:07:51,840 --> 00:07:58,110
So if we have a look at chapter one, you can see this is all we had at the point when we made our first

91
00:07:58,110 --> 00:07:58,530
commit.

92
00:07:58,830 --> 00:08:04,200
So previously we said that we have a working directory, which is the directory where we initialized

93
00:08:04,210 --> 00:08:04,560
Git.

94
00:08:05,100 --> 00:08:10,730
Then we can push our files to a staging area where we can pick and choose which files we want to commit.

95
00:08:11,070 --> 00:08:18,660
Then once we're ready, then we can commit our files or our save point to our local repository.

96
00:08:19,110 --> 00:08:26,850
So once you've done a few commits, then you actually have this timeline of various commits and this

97
00:08:26,850 --> 00:08:28,700
is called your master branch.

98
00:08:29,160 --> 00:08:36,060
So the Master Branch is your main branch of commits or save points and it is sequential.

99
00:08:36,360 --> 00:08:41,600
And this is usually where your main progress is saved or committed.

100
00:08:42,360 --> 00:08:48,660
Now, later on, we then introduced this idea of the remote repository.

101
00:08:48,840 --> 00:08:54,840
The important thing to note is that you can have a local repository completely in parallel with a remote

102
00:08:54,840 --> 00:08:55,470
repository,

103
00:08:55,680 --> 00:09:01,440
check the differences between them, but you can also sync them or push things from your local repository

104
00:09:01,440 --> 00:09:02,790
to your remote repository.

105
00:09:03,060 --> 00:09:09,510
So in our case, the local repository is the Git file that we've got inside our story directory.

106
00:09:09,870 --> 00:09:17,190
And the remote repository is GitHub which hosts our code and also hosts all of the changes that were

107
00:09:17,190 --> 00:09:19,140
made in between the different committees.

108
00:09:19,140 --> 00:09:24,810
So we have this master branch of various commits, first commit, second commit, third commit, in our

109
00:09:24,810 --> 00:09:26,490
local Git repository.

110
00:09:26,850 --> 00:09:34,980
And when we performed the command git push, then that effectively pushed all of those commits, all

111
00:09:34,980 --> 00:09:42,680
of those various versions and changes and code pieces to our remote repository on GitHub.

112
00:09:43,080 --> 00:09:44,580
So that's what git pushed us.

