1
00:00:04,460 --> 00:00:08,420
Online Git Repositories
enable you to store

2
00:00:08,420 --> 00:00:12,260
a copy of your Git Repository online.

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

4
00:00:19,630 --> 00:00:24,618
Let's learn about two of the online
Git Repositories service

5
00:00:24,618 --> 00:00:29,576
providers,GitHub and Bitbucket and
a little bit more detailed.

6
00:00:29,576 --> 00:00:34,670
They will look at how we can
set up our local Git Repository

7
00:00:34,670 --> 00:00:38,040
to be mirrored in
an online Git Repository.

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

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

10
00:00:48,590 --> 00:00:53,770
I will go through in more detail about how
you can set up your Git repository that

11
00:00:53,770 --> 00:00:58,970
you prepared in the previous exercise to

12
00:01:00,320 --> 00:01:04,220
be mirrored on an online Git
repository on Bitbucket.

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

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

15
00:01:15,590 --> 00:01:20,340
So here I have,
signed up into my Bitbucket account, and

16
00:01:20,340 --> 00:01:23,260
I have my homepage open here.

17
00:01:23,260 --> 00:01:27,240
And so, I'm going to create
a new repository online,

18
00:01:27,240 --> 00:01:30,020
on my Bitbucket repository.

19
00:01:30,020 --> 00:01:33,070
So, I just click on that
Create repository and

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

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

22
00:01:40,480 --> 00:01:48,150
So here, I will specify the name
of the repository as git-test.

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

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

25
00:01:58,050 --> 00:02:02,490
I will strongly advice you
to keep your repositories

26
00:02:02,490 --> 00:02:06,580
as private repositories because you
don;'t want somebody out to be copying

27
00:02:06,580 --> 00:02:10,420
the code that you might see in
your online git repository so

28
00:02:10,420 --> 00:02:17,190
please make sure that you only use private
repository in this specialization.

29
00:02:17,190 --> 00:02:21,020
So, I will sign up as get
private repository and

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

31
00:02:23,840 --> 00:02:30,320
And then, it will do some set up,
and then be very for me okay?

32
00:02:30,320 --> 00:02:32,780
Now what I need to do.

33
00:02:32,780 --> 00:02:36,960
Is to copy this particular
URL format repository.

34
00:02:36,960 --> 00:02:45,320
So, you will see a URL format repository
in the home page of that repository.

35
00:02:45,320 --> 00:02:50,700
So, just copy that URL format
repository because we would need that

36
00:02:50,700 --> 00:02:56,199
in order to Synchronise our local
Git repository with this repository.

37
00:02:56,199 --> 00:02:57,760
So, I'm going to copy that and

38
00:02:57,760 --> 00:03:03,410
since I have already created my local Git
repository I'm going to go in there and

39
00:03:03,410 --> 00:03:08,190
set that up to be mirrored in
this online Git repository.

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

41
00:03:15,600 --> 00:03:20,760
Going to the command prompt
in my Git repository folder,

42
00:03:20,760 --> 00:03:27,267
I will type git remote add origin and

43
00:03:27,267 --> 00:03:33,000
then paste the URL for my bitbucket

44
00:03:33,000 --> 00:03:38,465
repository that I've just created and
Hit the Return.

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

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

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

48
00:03:59,180 --> 00:04:03,340
So, reviewing the commands for
setting up the online git repository.

49
00:04:03,340 --> 00:04:08,310
The first one that we did, git remote
add origin and the repository URL.

50
00:04:08,310 --> 00:04:11,830
And so, this will add the online

51
00:04:11,830 --> 00:04:16,960
repository as the remote repository for
my local Git repository.

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

53
00:04:22,290 --> 00:04:27,990
For that I do git push -u origin master.

54
00:04:27,990 --> 00:04:33,910
And this command will push the local git
repository to the online repository.

55
00:04:33,910 --> 00:04:36,666
So, let's type that at the command prompt.

56
00:04:45,011 --> 00:04:48,916
So once I type this at
the command prompt and

57
00:04:48,916 --> 00:04:54,260
hit the return it's going to
set up my get repository.

58
00:04:54,260 --> 00:05:00,140
Sometimes it may ask you to type in
your credentials including your password

59
00:05:01,760 --> 00:05:05,660
on your Bitbucket account,
so you may have to do that.

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

61
00:05:09,150 --> 00:05:10,040
the password.

62
00:05:10,040 --> 00:05:13,100
But once I tied that in, then

63
00:05:13,100 --> 00:05:18,068
the contents of my local Git repository
will be pushed to the server side.

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

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

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

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

68
00:05:38,400 --> 00:05:41,400
you would see that there has been.

69
00:05:43,550 --> 00:05:48,930
Branch, the master branch that has been
pushed to my Online Git Repository.

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

71
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

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

73
00:06:04,150 --> 00:06:09,480
So, I can look at the state in the second
commit and at the first commit.

74
00:06:09,480 --> 00:06:15,760
So you can now see that all this
information has been upload it to

75
00:06:15,760 --> 00:06:21,510
the online depository,
including the history of all the commits.

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

77
00:06:26,550 --> 00:06:31,770
of the commits that have been
sent to the server site.

78
00:06:31,770 --> 00:06:35,510
I can examine each of those
commits in a bit more detail and

79
00:06:35,510 --> 00:06:42,750
then going back to that source I can look
at more details of the source like that.

80
00:06:42,750 --> 00:06:46,060
So that has now set up my

81
00:06:47,140 --> 00:06:51,691
local git repository in the package.

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

83
00:06:56,820 --> 00:06:59,590
So, let me setup an online
GitHub repository.

84
00:06:59,590 --> 00:07:04,540
Now obviously you have to remember
that your local repository can only be

85
00:07:04,540 --> 00:07:08,770
matched to one online git repository.

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

87
00:07:13,750 --> 00:07:18,330
that the same kind of commands would
be required if you want to set up

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

89
00:07:23,470 --> 00:07:27,340
So on GitHub,
if you login to your account,

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

91
00:07:30,570 --> 00:07:35,160
You can go to the right hand side where
there is a plus sign then click on that to

92
00:07:35,160 --> 00:07:40,715
create a new repository or just click on
this button here to say new repository.

93
00:07:40,715 --> 00:07:45,480
And then when it comes up
I can simply say git-test.

94
00:07:45,480 --> 00:07:50,735
And then, again as a reminder,
please make that a private repository.

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

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

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

98
00:08:05,360 --> 00:08:08,620
the moment unless if you're
working with a team.

99
00:08:09,770 --> 00:08:14,635
So, simply click on private and
then create repository.

100
00:08:14,635 --> 00:08:17,095
And then, that will create a repository.

101
00:08:17,095 --> 00:08:19,915
And then,
you will see that GitHub also gives me

102
00:08:19,915 --> 00:08:24,575
a bunch of commands here on
how to set up the repository.

103
00:08:24,575 --> 00:08:27,745
So, for creating a new
repository on the command line,

104
00:08:27,745 --> 00:08:31,055
the commands that we
actually had done earlier.

105
00:08:31,055 --> 00:08:32,995
Or to push an existing repository,

106
00:08:32,995 --> 00:08:36,395
the same two kinds of commands
that have to be issued.

107
00:08:38,040 --> 00:08:43,420
So, that basically sets up
your git hub repository

108
00:08:43,420 --> 00:08:48,440
to met your local repository.

109
00:08:48,440 --> 00:08:53,840
So, since I have already linked
my repository to Bitbucket I'm

110
00:08:53,840 --> 00:08:57,990
not going to use my GitHub repository for
the purpose so

111
00:08:59,810 --> 00:09:05,400
as you notice, the procedure is pretty
much similar on either one of them.

112
00:09:05,400 --> 00:09:10,800
Give and take a few differences
in the way the infornation

113
00:09:10,800 --> 00:09:15,230
is rendered on the screen in the user
interface and a little bit of changes.

114
00:09:15,230 --> 00:09:20,650
More or less, they are similar in
the way you're going to make use of them

115
00:09:20,650 --> 00:09:26,640
in terms of middling your local Git
repository to the online repository here.

116
00:09:27,650 --> 00:09:33,100
So with this, suppose somebody
gives you a Git repository.

117
00:09:33,100 --> 00:09:37,040
Can you make a copy of
that onto your local one.

118
00:09:37,040 --> 00:09:41,430
So this is where we use another
Git command called Git Claw.

119
00:09:41,430 --> 00:09:45,090
So now, here you'll see that I
have this git-test repository.

120
00:09:45,090 --> 00:09:50,350
So what I'm going to do is,
I'm going to go to this repository and

121
00:09:50,350 --> 00:09:56,580
then copy this URL and
then I'll show you how I can

122
00:09:56,580 --> 00:10:01,270
create a copy of that Git repository or

123
00:10:01,270 --> 00:10:05,840
clone this online repository
into my local computer.

124
00:10:05,840 --> 00:10:09,380
So, let's pretend that I
am on different computer.

125
00:10:09,380 --> 00:10:12,790
And then, we'll go to our command line and

126
00:10:12,790 --> 00:10:16,720
then create another repository
with the same name.

127
00:10:19,120 --> 00:10:23,110
Going to my command line,
I'm just going to move up into my earn.

128
00:10:23,110 --> 00:10:26,050
You see that I have my
git-test folder there.

129
00:10:26,050 --> 00:10:31,167
So I'm going to create
another temporary folder here

130
00:10:31,167 --> 00:10:37,000
just to show you that I can
clone an online git repository.

131
00:10:37,000 --> 00:10:39,900
So, in my temporary folder
you see that it is empty.

132
00:10:41,120 --> 00:10:46,570
So, to review the command it says,
git clone and the repository's URL.

133
00:10:46,570 --> 00:10:50,540
So, let's apply this command and
then clone that online git repository.

134
00:10:51,790 --> 00:10:56,742
Pretending that we are on another
computer, so I'm going to say,

135
00:10:56,742 --> 00:11:05,710
git clone and then, Paste the URL
of my bitbucket repository here.

136
00:11:05,710 --> 00:11:10,230
And then, you would see that
repository would now get cloned

137
00:11:10,230 --> 00:11:13,820
into a local folder with
the same name git-test.

138
00:11:13,820 --> 00:11:18,770
So now,
if I do a listing of the directory,

139
00:11:18,770 --> 00:11:21,590
you can see that the git-test
folder has been created.

140
00:11:21,590 --> 00:11:27,030
So, let's go to the git-test folder and
you will see that

141
00:11:27,030 --> 00:11:32,130
this is an exact copy of the folder
structure that we had created earlier.

142
00:11:32,130 --> 00:11:37,480
So this is how you can clone
an online Git repository.

143
00:11:37,480 --> 00:11:42,310
So, all you need to do is to obtain
the URL of that Git repository and

144
00:11:42,310 --> 00:11:48,090
then simply use git-clone to Get a copy
of that onto your local computer.

145
00:11:49,910 --> 00:11:56,670
With this, we complete this exercise
on using online Git repositories.

146
00:11:56,670 --> 00:11:58,112
So, did you finally Git it?

147
00:11:58,112 --> 00:12:01,329
[MUSIC]