1
00:00:01,040 --> 00:00:02,400
[Autogenerated] So next we're gonna tackle

2
00:00:02,400 --> 00:00:04,270
the process of understanding, get sub

3
00:00:04,270 --> 00:00:07,160
modules and what they provide. Let's first

4
00:00:07,160 --> 00:00:09,060
talk about different ways that we can

5
00:00:09,060 --> 00:00:11,210
utilize code from other get repositories.

6
00:00:11,210 --> 00:00:13,100
And remember, our goal here is that we

7
00:00:13,100 --> 00:00:14,760
could have shared repositories that can be

8
00:00:14,760 --> 00:00:17,580
used across projects. The first approach

9
00:00:17,580 --> 00:00:20,010
is you can leverage a package manager, one

10
00:00:20,010 --> 00:00:21,760
that specific for the technology that

11
00:00:21,760 --> 00:00:23,290
you're working in. This could be a

12
00:00:23,290 --> 00:00:25,900
solution, like in PM or Newgate or Ruby

13
00:00:25,900 --> 00:00:28,340
gems. The next approach is utilizing

14
00:00:28,340 --> 00:00:30,290
something called Get sub Trees. Now this

15
00:00:30,290 --> 00:00:32,050
is an emerging approach, and it does

16
00:00:32,050 --> 00:00:34,520
leverage a command Get sub tree. However,

17
00:00:34,520 --> 00:00:37,350
we also have get sub modules and get some

18
00:00:37,350 --> 00:00:39,380
modules are the most common approach for

19
00:00:39,380 --> 00:00:41,620
integrating other repositories, and it is

20
00:00:41,620 --> 00:00:42,790
the approach that's been around the

21
00:00:42,790 --> 00:00:44,750
longest, and so we're going to choose to

22
00:00:44,750 --> 00:00:47,400
focus on get sub modules. So for a quick

23
00:00:47,400 --> 00:00:49,760
definition, hey, get sub module is just a

24
00:00:49,760 --> 00:00:52,230
construct within get That enables you to

25
00:00:52,230 --> 00:00:54,380
keep a separate git repositories as a

26
00:00:54,380 --> 00:00:56,360
subdirectory within an existing

27
00:00:56,360 --> 00:00:58,420
repositories. So this enables you to

28
00:00:58,420 --> 00:01:00,460
effectively keep two separate repositories

29
00:01:00,460 --> 00:01:02,820
linked together within a project. So let's

30
00:01:02,820 --> 00:01:05,100
see how this plays out. So here we have

31
00:01:05,100 --> 00:01:07,360
our normal get repositories, and within

32
00:01:07,360 --> 00:01:09,240
this we're gonna have our working copy,

33
00:01:09,240 --> 00:01:10,710
and all of this exists within our

34
00:01:10,710 --> 00:01:12,980
repositories. But then we can look to

35
00:01:12,980 --> 00:01:15,050
integrate a separate repositories. In this

36
00:01:15,050 --> 00:01:17,530
case, we have sub module A, and this is

37
00:01:17,530 --> 00:01:19,640
held under a directory, external slash,

38
00:01:19,640 --> 00:01:21,610
sub module A. And then we could have

39
00:01:21,610 --> 00:01:23,970
another one, even some module B, and this

40
00:01:23,970 --> 00:01:25,650
one would be an external slash. So much

41
00:01:25,650 --> 00:01:27,880
will be. But then it goes even deeper than

42
00:01:27,880 --> 00:01:30,230
this because you can also have nesting. So

43
00:01:30,230 --> 00:01:32,120
we could even potentially have to separate

44
00:01:32,120 --> 00:01:35,440
sub modules that exist under sub module A.

45
00:01:35,440 --> 00:01:37,310
So with this being the case, let's talk

46
00:01:37,310 --> 00:01:40,470
through a few facts about get sub modules.

47
00:01:40,470 --> 00:01:43,160
First of all, utilizing sub modules does

48
00:01:43,160 --> 00:01:45,110
add complexity, especially when you're

49
00:01:45,110 --> 00:01:47,060
working with the team. So you want to be

50
00:01:47,060 --> 00:01:48,730
sure that you understand the guidelines

51
00:01:48,730 --> 00:01:50,220
that you need to follow, and we'll be

52
00:01:50,220 --> 00:01:52,150
covering those in more detail later on.

53
00:01:52,150 --> 00:01:55,210
Within this module next package, managers

54
00:01:55,210 --> 00:01:57,520
should be leveraged if possible. Package

55
00:01:57,520 --> 00:01:59,710
managers have scripted many aspects of

56
00:01:59,710 --> 00:02:01,410
taking specific versions of a get

57
00:02:01,410 --> 00:02:03,780
repositories, making them available in an

58
00:02:03,780 --> 00:02:05,210
easy way to include within one of your

59
00:02:05,210 --> 00:02:07,120
projects. There will be much more

60
00:02:07,120 --> 00:02:09,210
additional work if you choose to go the

61
00:02:09,210 --> 00:02:11,360
sub module route over the package manager

62
00:02:11,360 --> 00:02:14,160
round. However, sub modules are the fully

63
00:02:14,160 --> 00:02:16,550
supported way to include other repose into

64
00:02:16,550 --> 00:02:19,090
your project, And sub modules as mentioned

65
00:02:19,090 --> 00:02:21,260
are the most common manner to include

66
00:02:21,260 --> 00:02:22,860
other repositories and you'll see this

67
00:02:22,860 --> 00:02:24,550
approach leveraged in many open source

68
00:02:24,550 --> 00:02:26,970
projects. So let's next look at how you

69
00:02:26,970 --> 00:02:30,060
add a sub module. So get does have a sub

70
00:02:30,060 --> 00:02:32,010
module sub command that you can leverage.

71
00:02:32,010 --> 00:02:33,510
And in this case, we're going to pass in

72
00:02:33,510 --> 00:02:35,810
the ad command to that and then pass in

73
00:02:35,810 --> 00:02:37,710
the repo that we want to add, followed

74
00:02:37,710 --> 00:02:39,840
then by the directory that we want to live

75
00:02:39,840 --> 00:02:42,780
in within our current depository. Now

76
00:02:42,780 --> 00:02:44,650
there is a file that gets created the

77
00:02:44,650 --> 00:02:46,760
first time we had a sub model, which is

78
00:02:46,760 --> 00:02:49,810
our dot Get modules file. Now, this file

79
00:02:49,810 --> 00:02:52,560
will be checked in to our remote, and this

80
00:02:52,560 --> 00:02:54,440
is what allows us to then share this with

81
00:02:54,440 --> 00:02:56,040
other members of our team that are gonna

82
00:02:56,040 --> 00:02:58,940
be leveraging the same get sub modules

83
00:02:58,940 --> 00:03:00,670
because in this case, there is a process

84
00:03:00,670 --> 00:03:02,320
with some modules where it will take this

85
00:03:02,320 --> 00:03:04,360
information and then integrated in with

86
00:03:04,360 --> 00:03:06,420
the config for your repositories. Now

87
00:03:06,420 --> 00:03:08,280
you'll notice this looks much like the

88
00:03:08,280 --> 00:03:10,350
configuration files that we covered in a

89
00:03:10,350 --> 00:03:12,270
previous module, and that is very true.

90
00:03:12,270 --> 00:03:14,210
Much of this will get integrated in within

91
00:03:14,210 --> 00:03:16,040
your get configuration for your specific

92
00:03:16,040 --> 00:03:18,510
repositories, but for each sub module, two

93
00:03:18,510 --> 00:03:20,730
pieces of data are included. First, the

94
00:03:20,730 --> 00:03:22,850
path within the current depository and in

95
00:03:22,850 --> 00:03:24,300
the U. R L for the remote that we're

96
00:03:24,300 --> 00:03:27,060
pulling it from. Let's look next and how

97
00:03:27,060 --> 00:03:29,310
you clone a repositories that has some

98
00:03:29,310 --> 00:03:31,790
modules in it. So if you pull down a

99
00:03:31,790 --> 00:03:33,840
depository that has some modules, you can

100
00:03:33,840 --> 00:03:36,240
utilize clone Justus you have before. But

101
00:03:36,240 --> 00:03:39,200
next, you'll need to admit the sub module,

102
00:03:39,200 --> 00:03:40,750
and by doing that, you'll then integrate

103
00:03:40,750 --> 00:03:42,240
that in with the config for your local

104
00:03:42,240 --> 00:03:44,590
repositories. Once you do that, you can

105
00:03:44,590 --> 00:03:46,040
run the Update Command, which will

106
00:03:46,040 --> 00:03:48,610
actually grab the content of the reference

107
00:03:48,610 --> 00:03:50,860
for the specific commit of that sub

108
00:03:50,860 --> 00:03:52,750
module. Then we can talk about how you

109
00:03:52,750 --> 00:03:54,660
actually remove a sub module from a

110
00:03:54,660 --> 00:03:56,650
repositories. Now there are two different

111
00:03:56,650 --> 00:03:58,550
approaches you can take if you just want

112
00:03:58,550 --> 00:04:00,550
to temporarily remove it. You can use the

113
00:04:00,550 --> 00:04:02,660
D N a command, and that will remove it.

114
00:04:02,660 --> 00:04:04,940
But you can also go back and in it again

115
00:04:04,940 --> 00:04:07,200
at a later time. You also can permanently

116
00:04:07,200 --> 00:04:09,140
remove it by running the D N a command,

117
00:04:09,140 --> 00:04:11,360
followed by get R M and then committing

118
00:04:11,360 --> 00:04:13,810
your repositories with that change. Now

119
00:04:13,810 --> 00:04:15,710
let's talk about a few facts of working

120
00:04:15,710 --> 00:04:18,170
with gets up modules. First of all, sub

121
00:04:18,170 --> 00:04:21,560
modules are truly their own repositories.

122
00:04:21,560 --> 00:04:23,510
So that means once you change into that

123
00:04:23,510 --> 00:04:25,990
directory, you're utilizing the config of

124
00:04:25,990 --> 00:04:28,070
that repositories you're committing to

125
00:04:28,070 --> 00:04:30,060
that specific repositories. And when you

126
00:04:30,060 --> 00:04:31,860
push your pushing the contents of that

127
00:04:31,860 --> 00:04:33,900
repositories. So it's very important when

128
00:04:33,900 --> 00:04:35,390
you're working with sub modules to know

129
00:04:35,390 --> 00:04:37,000
what director you're in and what

130
00:04:37,000 --> 00:04:39,390
repositories or working with now. Sub

131
00:04:39,390 --> 00:04:41,610
modules do not track to a branch, but

132
00:04:41,610 --> 00:04:43,860
rather to a specific commit Now. This is

133
00:04:43,860 --> 00:04:45,890
to your advantage. You can make sure that

134
00:04:45,890 --> 00:04:47,930
someone else doesn't have the ability to

135
00:04:47,930 --> 00:04:49,740
change the code that is included in your

136
00:04:49,740 --> 00:04:51,920
project because you have to update

137
00:04:51,920 --> 00:04:54,330
explicitly if you want to include the new

138
00:04:54,330 --> 00:04:56,590
code for your sub module. Now, as

139
00:04:56,590 --> 00:04:58,830
mentioned sub modules can also contain

140
00:04:58,830 --> 00:05:00,850
other sub modules, and while that adds

141
00:05:00,850 --> 00:05:02,740
some complexity will walk through that

142
00:05:02,740 --> 00:05:06,340
also in a later clip. In addition, you can

143
00:05:06,340 --> 00:05:08,640
edit an update your sub modules within

144
00:05:08,640 --> 00:05:13,000
your project, just as you would any other normal repositories.

