fetch

Git Tutorial: All About Submodules



Sharing buttons:

hi my name is bread I'm a dead parrot

access soft and I want to talk a little

bit about sub modules so really all that

a sub module is is that it's a git

repository within another git repository

and it's a great way just to pull in

code that you find somewhere else on

github just to use in your app so let's

take this repository as an example it's

just a little app that draws some stick

figures and I found an awesome git repo

that already does all the styling for me

so what I can do is that I can add this

repository as a sub module in my own

repo and now I can actually start to use

everything with the styling library in

with my stick figure whenever you do add

a sub-module there's a couple things

that do happen it does actually clone

all of the files into your repo so you

can go and use them so you have the full

git history right there that you can go

and view and it also just makes a

reference just to be able to find the

repo as well not only is it a reference

to the repo it's a reference to a

specific commit in the repo whenever you

do actually add it you would probably

see in your git history it would just

show the name of the sub-module

in this case of styles and it'll show

what specific commits we're pointing to

and in this case it is abc123 it's the

full shawl hash of that commit here we

can see it's this commit right here

where we just added hats when I pull it

in my repository I can go in you know I

can start adding pants because I'm using

this library and I can go hats as well a

couple implications of actually pointing

to a specific commit is that I'm I now

am in control of what version of the

sub-module that I'm pulling it this

means that if they push an update they

do a bug fix I'm always going to be

pointing to the same place in time

they're not going to break whatever I'm

working on just because they made an

update it also means that anyone else on

my team that pulls down my repo they

would pull down the sub-module it would

look at what rebo's looking at would

commit and now they're using the exact

same version as me when you do want to

update what version of the sub-module

you're using all you need to do is just

go into the sub-module

because it's

get repository and just check out the

version that you want let's say okay

they added another feature where they

can go and include mustaches I would

just go check out this latest commit and

now in my 'get history it would just

show styles and the hash of this

commitment so now I'm pointing right

here to where they add some mustaches

and I can start using those as well and

this is helpful because in my repository

in the git history there it shows which

version of the sub-module

I was using at every point in time if I

ever have to go back or change branches

to an earlier version it'll look and see

what version of the sub-module

I was using check out to that specific

commit so I'm using the same version of

the sub-module that I was using at that

point in time and that's really all that

there is thanks for watching and I'll

see you next