1
00:00:00,000 --> 00:00:04,213
[MUSIC]

2
00:00:04,213 --> 00:00:08,838
Online Git repositories
enable you to store a copy

3
00:00:08,838 --> 00:00:12,260
of your Git repository online.

4
00:00:12,260 --> 00:00:19,630
And it can easily be shared among
multiple computers and multiple users.

5
00:00:19,630 --> 00:00:25,730
Let's learn about two of the online
Git repository service providers,

6
00:00:25,730 --> 00:00:29,030
GitHub and
Bitbucket in a little bit more detail.

7
00:00:30,060 --> 00:00:35,097
We'll look at how we can setup
our local Git repository

8
00:00:35,097 --> 00:00:39,158
to be mirrored in
an online Git repository.

9
00:00:39,158 --> 00:00:43,590
There are several online Git
repository service providers.

10
00:00:43,590 --> 00:00:48,590
Two of the most popular ones
are GitHub and Bitbucket.

11
00:00:48,590 --> 00:00:54,010
I will go through in more detail about how
you can setup your Git repository that you

12
00:00:55,500 --> 00:00:59,337
prepared in the previous exercise to be

13
00:00:59,337 --> 00:01:04,220
mirrored on an online Git
repository on Bitbucket.

14
00:01:05,680 --> 00:01:10,890
To set up an online Git repository,

15
00:01:10,890 --> 00:01:15,680
go to one of these online service
providers and then sign up for an account.

16
00:01:15,680 --> 00:01:20,201
So here, I have signed up
into my Bitbucket account and

17
00:01:20,201 --> 00:01:22,676
I have my home page open here.

18
00:01:22,676 --> 00:01:25,740
And so I'm going to create a new

19
00:01:25,740 --> 00:01:30,020
repository online on my
Bitbucket repository.

20
00:01:30,020 --> 00:01:33,070
So I just clicked on it,
create repository, and

21
00:01:33,070 --> 00:01:36,245
then this would come up with some details.

22
00:01:36,245 --> 00:01:40,480
Now, this varies with
the repository service provider.

23
00:01:40,480 --> 00:01:48,150
So here, I will specify the name of
the repository and and skit test.

24
00:01:48,150 --> 00:01:52,810
And I'm going to mark this
as a private repository.

25
00:01:52,810 --> 00:01:58,050
For this course and all the remaining
courses in this specialization,

26
00:01:58,050 --> 00:02:04,090
I would strongly advise you to keep your
repositories as private repositories,

27
00:02:04,090 --> 00:02:08,510
because you don't want somebody else to
be copying a code that you might save

28
00:02:08,510 --> 00:02:10,130
in your online Git repository.

29
00:02:10,130 --> 00:02:11,340
So, please,

30
00:02:11,340 --> 00:02:17,190
make sure that you only used private
repositories in this specialization.

31
00:02:17,190 --> 00:02:21,020
So I will sign up as a Git
private repository, and

32
00:02:21,020 --> 00:02:23,840
then simply click on, Create repository.

33
00:02:23,840 --> 00:02:30,303
And then it will do some set up and
then be ready for me, okay?

34
00:02:30,303 --> 00:02:36,910
Now, what I need to do is to copy this
particular URL format repository.

35
00:02:36,910 --> 00:02:45,208
So you will see URL for the repository
in the Homepage of that repository.

36
00:02:45,208 --> 00:02:48,244
So just copy that URL for the repository,

37
00:02:48,244 --> 00:02:52,583
because we would need that in
order to synchronize our local

38
00:02:52,583 --> 00:02:57,630
Git repository with this repository,
so I'm going to copy that.

39
00:02:57,630 --> 00:03:02,764
And since I have already created my
local Git repository, I'm going to

40
00:03:02,764 --> 00:03:08,190
go in there and set that up to be
mirrored in this online Git repository.

41
00:03:08,190 --> 00:03:14,140
So for that, we need to use a couple of
Git commands that enable us to do this.

42
00:03:15,600 --> 00:03:22,597
Going to the command prompt
in my Git repository folder,

43
00:03:22,597 --> 00:03:26,839
I will type git remote add origin.

44
00:03:26,839 --> 00:03:32,175
And then paste the URL for
my Bitbucket repository

45
00:03:32,175 --> 00:03:38,282
that I have just created,
and, Hit the return.

46
00:03:38,282 --> 00:03:46,895
So now, my local Git repositories remote
origin is set to the Bitbucket repository.

47
00:03:46,895 --> 00:03:51,955
So now,
I want to be able to push the entire

48
00:03:51,955 --> 00:03:57,165
contents of my local Git repository
to my online Git repository.

49
00:03:59,180 --> 00:04:03,650
So reviewing the commands for
setting up the online Git repository,

50
00:04:03,650 --> 00:04:08,671
the first one that we just did, Git
remote add origin and the repository URL.

51
00:04:08,671 --> 00:04:14,284
And so this will add the online
repository as the remote repository for

52
00:04:14,284 --> 00:04:16,960
my local Git repository.

53
00:04:16,960 --> 00:04:22,290
Once I do that, then I need to push
my contents to my online repository.

54
00:04:22,290 --> 00:04:27,990
For that,
I'll do Git push-u origin master.

55
00:04:27,990 --> 00:04:33,910
And this command would push the local
Git repository to the online repository.

56
00:04:33,910 --> 00:04:36,546
So let's type that,
add the command prompt.

57
00:04:45,014 --> 00:04:48,886
So once I typed this at
the command prompt and

58
00:04:48,886 --> 00:04:54,260
hit the Return,
it's going to setup my Git repository.

59
00:04:54,260 --> 00:04:59,060
Sometimes, it may ask you to
type in your credentials,

60
00:04:59,060 --> 00:05:05,660
including your password on your Bitbucket
account so you may have to do that.

61
00:05:05,660 --> 00:05:09,241
I had already done that previously, so
that's why it didn't ask me again for

62
00:05:09,241 --> 00:05:09,966
the password.

63
00:05:09,966 --> 00:05:14,438
But once I've typed that in,
then the contents of my local Git

64
00:05:14,438 --> 00:05:18,068
repository will be pushed
to the server side.

65
00:05:18,068 --> 00:05:19,751
So now,

66
00:05:19,751 --> 00:05:25,120
the data on my local Git repository
is now matched of the server side.

67
00:05:25,120 --> 00:05:30,800
So let's go to Bitbucket to see the status
of my online Git repository now.

68
00:05:32,400 --> 00:05:38,400
Going to my Bitbucket and
then reviewing the online Git repository,

69
00:05:38,400 --> 00:05:44,320
you would see that there
has been a branch,

70
00:05:44,320 --> 00:05:48,930
the master branch, that has been
pushed to my online Git repository.

71
00:05:48,930 --> 00:05:52,620
I can then examine the source
by looking at the source here.

72
00:05:52,620 --> 00:05:57,280
And then you can see that I have the
index.html file which is exactly the same

73
00:05:57,280 --> 00:06:04,150
as what I have in my local Git repository,
and examine the various comments also,

74
00:06:04,150 --> 00:06:09,590
so I can look at the state in the second
comment and the first comment.

75
00:06:09,590 --> 00:06:14,706
So you can now see that all this
information has been uploaded

76
00:06:14,706 --> 00:06:21,510
to the online repository,
including the history of all the comments.

77
00:06:21,510 --> 00:06:26,600
Then going back there,
you can see more details about all

78
00:06:26,600 --> 00:06:31,770
the comments that have been
sent to the server side.

79
00:06:31,770 --> 00:06:35,350
I can examine each of those
comments in a bit more detail.

80
00:06:35,350 --> 00:06:38,350
And I'm going back to that source,

81
00:06:38,350 --> 00:06:42,750
I can look at more details
of the source like that.

82
00:06:42,750 --> 00:06:46,612
So that has now set up my local Git

83
00:06:46,612 --> 00:06:51,630
repository to be mirrored in Bitbucket.

84
00:06:51,630 --> 00:06:56,820
The procedure is pretty much
similar even on GitHub.

85
00:06:56,820 --> 00:07:00,070
So let me set up an online
GitHub repository.

86
00:07:00,070 --> 00:07:04,525
Obviously, you have to remember that
your local repository can only be

87
00:07:04,525 --> 00:07:08,770
matched to one online Git repository.

88
00:07:08,770 --> 00:07:13,750
So I will only go to setting up the
repository on GitHub, and you will notice

89
00:07:13,750 --> 00:07:18,330
that this same kind of commands will
be required if you want to set up

90
00:07:18,330 --> 00:07:23,470
your local repository to be
mirrored on a repository on GitHub.

91
00:07:23,470 --> 00:07:27,340
So on GitHub,
if you log in to your account,

92
00:07:27,340 --> 00:07:30,570
you would see something
like this in your Homepage.

93
00:07:30,570 --> 00:07:34,422
You can go to the right-hand side
where there's a plus sign, and

94
00:07:34,422 --> 00:07:37,294
then click on that to
create a new repository, or

95
00:07:37,294 --> 00:07:40,605
just click on this button
here to save your repository.

96
00:07:40,605 --> 00:07:45,210
And then when that comes up,
I can simply say git-test, and

97
00:07:45,210 --> 00:07:50,735
then again, as a reminder,
please make the private repository.

98
00:07:50,735 --> 00:07:55,755
Most of these providers allow you to
now store private repositories online.

99
00:07:55,755 --> 00:08:01,175
So, why make them public unless you really
want to share it with other people.

100
00:08:01,175 --> 00:08:05,350
So I would strongly urge you to
keep your repositories private for

101
00:08:05,350 --> 00:08:09,560
the moment unless if you're
working with a team.

102
00:08:09,560 --> 00:08:15,200
I should remind you that at this moment,
GitHub supports private repositories

103
00:08:15,200 --> 00:08:21,970
only for those subscribers who pay for
their GitHub account.

104
00:08:21,970 --> 00:08:27,670
So it is not available for subscribers
who are using their free account.

105
00:08:27,670 --> 00:08:31,884
So simply click on Private,
and then Create repository,

106
00:08:31,884 --> 00:08:34,812
and then that will create a repository.

107
00:08:34,812 --> 00:08:39,846
And then you would see that GitHub also
gives me a bunch of commands here on how

108
00:08:39,846 --> 00:08:45,650
to setup the repository, so for creating
a new repository on the command line.

109
00:08:45,650 --> 00:08:50,870
The commands that we actually had done
earlier or to push an existing repository,

110
00:08:50,870 --> 00:08:54,300
the same two kinds of commands
that have to be issued.

111
00:08:55,940 --> 00:09:01,260
So that basically sets up
your GitHub repository

112
00:09:01,260 --> 00:09:06,340
to mirror your local repository.

113
00:09:06,340 --> 00:09:10,990
So, since I have already linked
my repository to Bitbucket,

114
00:09:10,990 --> 00:09:15,600
I'm not going to use my GitHub
repository for the purpose.

115
00:09:15,600 --> 00:09:23,102
So as you notice, the procedure is pretty
much similar on either one of them.

116
00:09:23,102 --> 00:09:28,042
Give and take a few differences in
the way the information is rendered

117
00:09:28,042 --> 00:09:33,170
on the screen in the user interface and
a little bit of changes.

118
00:09:33,170 --> 00:09:38,410
More or less, they are similar in the way
you're going to make use of them in terms

119
00:09:38,410 --> 00:09:44,540
of mirroring your local Git repository
to the online repository here.

120
00:09:45,550 --> 00:09:50,990
So with this, suppose somebody
gives you a Git repository,

121
00:09:50,990 --> 00:09:54,940
can you make a copy of
that onto your local one?

122
00:09:54,940 --> 00:09:59,330
So this is where we use another
Git command called Git clone.

123
00:09:59,330 --> 00:10:02,794
So now, here, you see that I
have this git-test repository.

124
00:10:02,794 --> 00:10:08,395
So, what I'm going to do is I'm
going to go to the repository,

125
00:10:08,395 --> 00:10:10,520
and then copy this URL.

126
00:10:10,520 --> 00:10:17,330
And then I'll show you how I can
create a copy of the Git repository

127
00:10:18,590 --> 00:10:23,740
or clone this online repository
into my local computer.

128
00:10:23,740 --> 00:10:28,730
So let's pretend that I am on a different
computer, and then we'll go to our

129
00:10:29,900 --> 00:10:34,610
command line and then create another
repository with that same name.

130
00:10:37,020 --> 00:10:40,809
Going to my command line,
I'm just going to move up into my, and

131
00:10:40,809 --> 00:10:43,838
you'll see that I have my
git-test folder there.

132
00:10:43,838 --> 00:10:49,130
So I'm going to create another
temporary folder here,

133
00:10:49,130 --> 00:10:54,900
just to show you that I can
clone an online Git repository.

134
00:10:54,900 --> 00:10:57,790
So in my temporary folder,
you'll see that it is empty.

135
00:10:59,020 --> 00:11:04,470
So to review the command, it says
Git clone and the repository's URL.

136
00:11:04,470 --> 00:11:08,440
So let's apply this command and
then clone that online Git repository.

137
00:11:09,700 --> 00:11:14,617
Pretending that we are on another
computer, so I'm going to say,

138
00:11:14,617 --> 00:11:19,443
git clone and then, Paste the URL

139
00:11:19,443 --> 00:11:23,610
of my Bitbucket repository here.

140
00:11:23,610 --> 00:11:28,130
And then you would see that Git
repository will not get cloned

141
00:11:28,130 --> 00:11:31,930
into a local folder with
the same name git-test.

142
00:11:31,930 --> 00:11:36,670
So now,
if I do a listing of the directory,

143
00:11:36,670 --> 00:11:39,490
you can see that the git-test
folder has been created.

144
00:11:39,490 --> 00:11:44,930
So let's go to the git-test folder,
and then you will that

145
00:11:44,930 --> 00:11:50,030
this is an exact copy of the folder
structure that we had created earlier.

146
00:11:50,030 --> 00:11:55,181
So this is how you can clone
an online Git repository.

147
00:11:55,181 --> 00:12:00,391
So all you need to do is to obtain
the URL of that Git repository, and

148
00:12:00,391 --> 00:12:05,990
then simply use Git clone to get a copy
of that onto your local computer.

149
00:12:07,810 --> 00:12:14,414
With this, we complete this exercise
on using online Git repositories.

150
00:12:14,414 --> 00:12:16,083
So did you finally get it?

151
00:12:16,083 --> 00:12:19,229
[MUSIC]