PBS_2024_11_23
An audio podcast where Bart Busschots is teaching the audience to program. Associated tutorial shownotes are available at https://pbs.bartificer.net.
Automatic Shownotes
Chapters
Welcome to Programming by Stealth
Diving into Git Submodules
Understanding Submodules and Contexts
Simulating a Git Server
Setting Up Our Web App Scenario
Cloning a Repository with Submodules
Adding a Submodule to Your Project
Updating the Brand from the Designer
Consuming Updates from Submodules
Exploring Push and Pull in Submodules
Long Summary
Join us for installment 173 of Programming by Stealth as we delve into the intricacies of Git submodules, enhancing our understanding of this powerful version control tool. In this episode, I, Alison Sheridan, along with my co-host Bart Bouchotts, guide listeners through both theoretical and practical applications of Git submodules, utilizing real-life scenarios to illustrate their importance in software development.
We kick off the discussion by emphasizing the significance of knowing the foundational commands in Git. The first scenario revolves around a fictitious small software company that we simulate running a few web applications, setting the stage for our hands-on exercises. Our exploration begins with the concept of a Git repository nested within another—what we refer to as a submodule. We dive into the command line, getting our hands dirty with essential Git commands required for managing these submodules, ensuring that listeners not only grasp the theory but can also execute it practically.
Following our theoretical foundation, we walkthrough several constructed scenarios. The initial scenario introduces listeners to the common experience of cloning a repository that utilizes a submodule. Upon cloning a web app without the branded assets, we quickly diagnose why the brand's CSS doesn't appear correctly. After investigating with commands, we observe the nuances of the `.gitmodules` file and realize that while our app is set up to include a submodule called 'brand,’ it requires initialization and updating for it to function properly. Using commands such as `git submodule init` and `git submodule update`, we demonstrate the mechanics behind integrating the brand repository effectively.
As the episode progresses, we transition to adding submodules to our own projects. In this phase, we showcase how to bring another piece of code into an ongoing project while maintaining the integrity of our overall development strategy. We articulate the process of adding a submodule and utilizing proper flagging to clone it successfully in the context of our web apps. This not only clarifies how submodules integrate into existing projects but also highlights the importance of structured management of dependencies.
We also explore a key aspect of collaborating within a team: updating submodules after changes have been made. By playing the role of both brand designer and app developers, we illustrate how modifications in the submodule can be seamlessly integrated into the main applications. Our discussion details both the 'outside-in' and 'inside-out' approaches to using submodules, providing listeners with different perspectives on managing their project’s structure and versioning. Each method is broken down into actionable steps, promoting an understanding of when to apply each.
In conclusion, we emphasize that while submodules provide a method to pull code from one repository into another, they inherently rely on managing dependencies correctly. This episode aims not just to inform but also to empower developers in their use of Git, enhancing their workflow as they learn the tools that allow for efficient project management. We set the stage for a follow-up discussion, hinting at the capabilities of modifying submodules and branching for version control, ensuring that listeners are left with essential takeaways and excitement for the next installment.
We kick off the discussion by emphasizing the significance of knowing the foundational commands in Git. The first scenario revolves around a fictitious small software company that we simulate running a few web applications, setting the stage for our hands-on exercises. Our exploration begins with the concept of a Git repository nested within another—what we refer to as a submodule. We dive into the command line, getting our hands dirty with essential Git commands required for managing these submodules, ensuring that listeners not only grasp the theory but can also execute it practically.
Following our theoretical foundation, we walkthrough several constructed scenarios. The initial scenario introduces listeners to the common experience of cloning a repository that utilizes a submodule. Upon cloning a web app without the branded assets, we quickly diagnose why the brand's CSS doesn't appear correctly. After investigating with commands, we observe the nuances of the `.gitmodules` file and realize that while our app is set up to include a submodule called 'brand,’ it requires initialization and updating for it to function properly. Using commands such as `git submodule init` and `git submodule update`, we demonstrate the mechanics behind integrating the brand repository effectively.
As the episode progresses, we transition to adding submodules to our own projects. In this phase, we showcase how to bring another piece of code into an ongoing project while maintaining the integrity of our overall development strategy. We articulate the process of adding a submodule and utilizing proper flagging to clone it successfully in the context of our web apps. This not only clarifies how submodules integrate into existing projects but also highlights the importance of structured management of dependencies.
We also explore a key aspect of collaborating within a team: updating submodules after changes have been made. By playing the role of both brand designer and app developers, we illustrate how modifications in the submodule can be seamlessly integrated into the main applications. Our discussion details both the 'outside-in' and 'inside-out' approaches to using submodules, providing listeners with different perspectives on managing their project’s structure and versioning. Each method is broken down into actionable steps, promoting an understanding of when to apply each.
In conclusion, we emphasize that while submodules provide a method to pull code from one repository into another, they inherently rely on managing dependencies correctly. This episode aims not just to inform but also to empower developers in their use of Git, enhancing their workflow as they learn the tools that allow for efficient project management. We set the stage for a follow-up discussion, hinting at the capabilities of modifying submodules and branching for version control, ensuring that listeners are left with essential takeaways and excitement for the next installment.
Brief Summary
In this episode of Programming by Stealth, we explore Git submodules in depth, unearthing their significance in version control. Together with my co-host Bart Bouchotts, I provide a blend of theoretical insights and hands-on exercises designed to bolster your understanding of integrating submodules into projects. We kick off with foundational Git commands before diving into practical scenarios, such as cloning repositories and updating brand CSS through proper submodule management. Throughout the discussion, we emphasize the structured handling of dependencies and collaborative strategies for teams. Join us as we empower developers to enhance their workflow with Git, setting the stage for future discussions on modifying submodules and branching techniques.
Tags
Git submodules
version control
programming
Bart Bouchotts
theoretical insights
hands-on exercises
integrating submodules
cloning repositories
managing dependencies
collaborative strategies
workflow enhancement
Transcript
[0:00]Music
[0:07]Well, it's that time of the week again. It's time for Programming by Stealth,
[0:13]
Welcome to Programming by Stealth
[0:10]and this is installment 173, recorded November 23rd, 2024. I'm your host, Alison Sheridan. Of course, I'm joined by your co-host, Bart Bouchotts.
[0:21]Hello there. It is nice to be back.
[0:23]We have a new intro, and we're both struggling with, like, when are we supposed to talk, right? That was your intro. I guess I usually say welcome to the show, Bart.
[0:31]That's true. Yeah, I will get the hang of it. By episode 200, we'll be a pro.
[0:35]Probably. And then we'll change something.
[0:41]
Diving into Git Submodules
[0:38]Right, of course you will, because both of us do that all the time, always.
[0:42]All right. So I'm excited. We are going to get our fingers actually dirty in the terminal here on Git submodules, right?
[0:50]Yes, we are. And like we did with the original Git series, we are going to do it in the show notes the hard way on the terminal with the Git command. Because if you can do it with the Git commands, the same verbs, the same phrases will be in the right-click menus on things. They will be on the buttons in your git gui and so every git gui will be a little bit different but they're all going to be keying off the underlying concepts and they're all going to be keying off those real git commands under the hood so if you know the real git commands you should be able to use any gui and it saves us being sort of pedantic and say oh the gui we support is blah blah blah because i don't like the same gui forever so why would this show yeah.
[1:30]Yeah i and i kind of look at this as like you need to understand how to add and what it means to add and subtract, multiply, but it's okay to use a calculator.
[1:40]Yep, absolutely. You punch the buttons and hey presto. Yeah, absolutely.
[1:44]It's also how you can tell if something's wrong if you actually understand the underlying concepts of addition and subtraction and multiplication division.
[1:50]Fair point. Yes. Why do I owe the government more money than I made? Maybe I got something wrong in my math.
[1:58]Why did I
[1:58]Multiply by the wrong number?
[1:59]Oh, my units were wrong.
[2:02]Or that one, yeah. Yeah. Anyway, well, when we were last recording a month ago, we introduced the concept of a Git repository inside a Git repository, which in Git speak is called a submodule. And Git has commands for handling these submodules in a clever way, which is one of the many reasons Git is better than a lot of other version control systems. Because if you tried that on subversion, it would explode in a heap of incoherence. It couldn't handle nesting. I really couldn't handle that. So last time it was all theory and whetting your appetite and saying the kinds of problems it could solve. And there are many, many kinds of problems it could solve. So this time we are getting our hands dirty, as you say, and we're going to do it by working off a simplified but realistic scenario. We're going to basically pretend to be a small software company that runs a few web apps and we're going to just play different parts. Now, the actual code is trivial, but it's not about the actual code. It's about the concept of nesting modules and pulling changes and so forth. So we're going to break it into two installments. So I have five scenarios invented, and three of them are for this week, or this installment, and then two of them are for the next time.
[3:19]Scenario is a little bit more complicated so that's why it's asymmetric um because our scenario of three is as big as one and two put together and three and four are chunky.
[3:29]
Understanding Submodules and Contexts
[3:30]Before we start into the detail here um on our slack potfi.com forward slash slack we had some discussions about this and i think you and i were having discussions anyway the community which is a great place and everyone should go we're having some discussions about whether you know git submodules how is that related to public repositories and the answer is they're separate context contexts so git is very at home in the open source world because that's literally where it came from git is equally at home sharing privately which is sounds mildly oxymoronic at first but when you think about it a private group is sharing privately so you and i have repositories that we share between us but are not shared with the rest of the world, companies tend to have private repositories but they could be shared by a thousand people big enough companies it could be shared by tens of thousands of people right so it's sharing in private and so you can use a git submodule either with a public repository could consume another public repository or a private repository could consume a public repository or a private repository could consume a private repository or a private repository could just mix and match you can't really have a public repository consuming private because that would break as soon as someone cloned the public repository. It wouldn't be public anymore if it had a private dependency. But basically, you can mix and match to your heart's content.
[4:50]I thought of a question I hadn't asked before. Can a submodule, can a Git repo be a submodule to two different repos?
[5:00]Yes. Not only that, but a submodule is just a repository you've put in a folder. So that one could have submodules too. So you could have four submodules at the top level, then one of those could have three submodules, and one of those could have two submodules. It could be submodules all the way down. Absolutely it can, yes. As many turtles as you like.
[5:21]Maybe I did ask that, because I remember making that joke last time, but hey, it was a month ago. Okay. But then the dependencies would be in a certain way, right? You couldn't have a private repo having a private submodule and then a public repo having that same private submodule that would break.
[5:42]It would. And the other thing is, if you make a circle, I think you get infinity and explosion. I think if you tried to put one into one it came from before, I think it would completely break everything. You'd run a git command and it would never end. And your hard drive would probably fill up as it cloned and cloned and cloned
[5:59]
Simulating a Git Server
[5:58]and cloned and cloned and cloned and cloned. It may have a safety valve built in it may have like a counter that if i am 500 deep stop i don't know um don't try while we're recording whenever you do try don't try while we're recording okay, um we are also back for the first time in a long time with uh installment resources because we are going to be playing along and we're going to have to do the trick we did way back in like installment 113 where we were learning about remote git repositories but i didn't want to set up a server that then would have to be online forever so we're going to simulate a server with a folder.
[6:36]And we're going to use a url that is a file path and that is perfectly fine git doesn't mind that it treats it just like it would if you're doing it over https or ssh it works fine however for a really good security reason git won't do that in some circumstances in case you're being tricked by a baddie so if you have if you imagine you clone something from a public repo and it then has some private some relative paths they could end up sucking in code from something that you really didn't know oh okay so they make you explicitly say to the git command no no no i'm good with using local file paths so we're going to have to do that in some of our commands.
[7:19]Now this basically this happens when you have one git command that implies other git commands, so if you do it directly by typing in git space clone space dot dot slash whatever git like well you've literally typed this in this is exactly what you meant i'm not going to make you prove it to me you've just told me to do this so.
[7:41]If the human's typing it's okay with it
[7:44]Exactly. It's like, okay, you meant this.
[7:46]But if you write one git command,
[7:48]And that git command triggers other git commands under the hood, and if the other git commands are where the file path appears.
[7:57]Then git was like, ooh, I'm being asked to do something implicit and in secret. I'm going to make you be explicit about this. And so there is an option, a configuration setting, that controls git's behavior for these types of URLs. And it's protocol.file.allow is the name of the setting which is not unreasonable and it has three values never which means I really don't care where I come across a file URL I am never ever ever ever ever going to use a file URL ever it has user which means if the user told me to directly and explicitly fine otherwise I'm cranky and that's the default is basically if you do it directly we're fine and the third setting is always in other words whether it's direct or indirect file URLs are fine so obviously we need to use the setting always now there is an aside in the show notes you could make that a permanent change you could add something to your global git configuration with git config minus minus global and then on your computer forevermore all file URLs would be allowed. There's a reason the default is user. So I'm telling you, this is how you do this terribly silly thing, but unless you really, really, really have a reason, maybe you work in a place where all of your repositories are on a NAS and you do everything over files? Okay.
[9:24]But don't ever do anything publicly. Don't ever do... Yeah. Okay. Exactly. I'm going to pretend you never
[9:29]Told us this. So for us, we're going to... Yeah. I edited the show notes just before we recorded to make this an aside, to make it really clear that this is really not what we're recommending to people.
[9:38]By the way, here's a stupid thing you could do if you wanted to. Don't do it.
[9:43]Well, unless you are one of the small group of people for which it's not stupid.
[9:47]Okay.
[9:48]Like I say, legitimate reasons. If you use NAS, yeah. So what we're going to do instead is do it on a per command basis. So as and when we want to make the exception, we make the exception there and then. So git takes an optional argument minus c for configuration, and it lets you set any configuration setting, and it will only last while that one command is running. So you say git minus c name of setting equals value, and then whatever else you were going to do, space, pull, push, whatever. And then that one setting only applies for that one iteration of the git command, and then it evaporates again, and it goes back to its default. So that's what we're going to do. We're going to do it on a per command basis.
[10:27]Okay, so it'll look kind of goofy in here. You wouldn't probably be doing it if you were doing it up in a Git repo, but for this, this would be fun. Yes.
[10:38]Exactly. So in the real world, you probably cloned over HTTPS or SSH. No problem. You won't need to do this minus C thing, but we're going to meet it a few times today. So I'm telling you about it. I also want to lay a little bit of a foundation to help us not confuse ourselves because submodules are nested repositories. So each submodule folder is a Git repository. So there are a lot of Git repositories at play in this conversation. Like, it's Git repositories all over the place. So to illustrate the scale of possible confusion, imagine we have our Git repository with two submodules. Straight away, that's three Git repositories. The outer container, which has a folder which contains another repository, and another folder which contains a third repository, we have three. But no, there's more, because a sub-module is always cloned from a URL, which means the sub-module always has a matching remote, which is the repository you got it from. So that means there's two of them.
[11:43]Wait a minute. If you say git... Stop, stop, stop. I don't buy that. I just created a folder inside my module. I'm sorry, inside my git repo, and I initialized it as a git repo. There are two.
[11:57]But that's not a sub-module. That's just a git repo and a git repo. If you add a submodule, you're giving it the URL of the code you want to fetch. The point of a submodule is to fetch another piece of code.
[12:09]Wait, you haven't taught us this yet, so I don't know that yet.
[12:12]I know what I'm saying.
[12:13]You said it's just a folder inside of a folder.
[12:17]Okay, but it's a folder from which you get another Git repository, right? You're getting someone else's code. So that means that it exists. There has to be somewhere to get it from. The somewhere is also a Git repository. When you clone these show notes, they exist on the server in GitHub, they exist on my computer, and they exist on your computer. There's three repos. GitHub, me, and you.
[12:44]Okay.
[12:46]Because remember, Git is peer-to-peer. There is no client server.
[12:49]They're all just repositories. Right, I understand that. Yeah. So we've got three copies of the repo.
[12:56]So there are... Right. Okay. So we have three completely different local repositories. And then each of those sub-modules are a copy of their source, which means that there are two more repositories. So, okay, we have five repositories, two of which are copies of each other. But there's still five repositories in play that i have to talk about that i have to describe because when you're pushing and pulling those are not perfect copies so.
[13:20]Hang on so but you're saying that i can't create a local repo a local initialize a local repo inside of a an existing repo on my computer and that be a sub module by definition it can never be one unless it's been cloned somewhere and i got it from that somewhere i can't create it myself i have to get it from
[13:40]Somewhere okay so if you make an empty folder and you make you just go get in it it is a git repository inside a git repository it's not a sub module it's just a repository inside a repository a sub module is that extra thing where you're intentionally taking someone else's content and bringing it in in a controlled way why.
[14:00]Can't it be
[14:00]My that's its job oh it can be yours it can't just or sorry by my i mean the repository that i'm adding this sub module to The point of a sub-module is to bring in content from another Git repository.
[14:15]Okay. I guess I'll have to see how it's different, because I thought once it was initialized, it was a sub-module, but maybe not.
[14:23]Let's keep going so.
[14:24]We can learn how we do this, and I'll see if I can find it. Okay.
[14:29]All right. So we're kind of proving the point of this room for confusion here, but there's actually a sixth repository, because the chances are extremely high that the one you're working in was cloned from a server. So when you're working on these show notes, they're cloned from GitHub. So that's, it has a remote. So, or in the case before you record it, you accidentally had four remotes. So that's another repository that's in play. So we have six repositories in play. Three of them are remote. Three of them are local. They're in pairs. We have three couples. We have three pairs of modules, but sorry, of repositories, but there's still six repositories. And I have to talk about these and I'm pushing and pulling between repositories. So we need to have some words to not make this even more confusing than it's going to be because it's repositories all the way down. So I'm going to refer to the repository that contains the submodules as the outer repository. And I'm going to talk about submodules either using the word submodule or inner repository, depending on which makes sense in the English sentence. And so when I say outer, I mean the one that has the submodules. And when I say inner, I mean I'm inside that folder now that is the submodule.
[15:38]Okay.
[15:39]And I'm going to be really consistent. I rewrote the show notes to make sure I was really consistent, because otherwise this is going to be trending. I may... See, I needed to say this up front, but yet, how do I say it up front? Yeah, we're in a circle here.
[15:53]Yeah, Bart's looking at my face going, okay. He knows what I mean when I say it, okay. Yeah.
[16:01]All right. So anyway, our scenario, we are a small web app business. And we are going to pretend that we are basically we're a company we develop some web apps and we share the same brand across all of our web apps because we want to keep them consistent these are our web apps right so they all look the same and we are going to have a git repository that contains just our brand and that's going to be managed by our design team because they know what they're doing with that kind of stuff and then our developers are going to have a separate git repository for each of our apps and we don't want to copy and paste our brand into our apps we want to incorporate the brand in a controlled way so obviously the brand should be a sub module inside app one and a sub module inside app two and so our brand developers will update our brand push it up to the server, we'll pull the changes down into our apps.
[17:00]
Setting Up Our Web App Scenario
[17:00]That is the big picture scenario we're setting up here.
[17:05]So for the first time in ages, there is a zip file in this installment. And if you expand it out, you will find it has some content. And if you go into that in your terminal, if you'd like to play along, there is a lot of setting up to do. So I've scripted the setting up. And because we've done bash, you can open the file and explore the bashy goodness to your heart's content if you like. But ultimately, if you run chmod plus x start at sh, basically says just make sure that shell script is executable. And then .slash init pbs173demo.sh and it will do all the work to get our pieces set up for us. So if you run that, the first thing it's going to do is to create four folders that are going to pretend to be different computers. So the first folder is pretending to be the Git server for our pretend company, which we're calling PBS Core or Corpse. I'm not quite sure how you pronounce it with a company. Is it Core?
[18:00]It's Core. Core, good.
[18:02]Good. PBS core. Then we have a folder called pc-app1dev. Shock and horror. That is the folder pretending to be app1developerspc.
[18:13]I'd like to make one little note. If you're looking at this with certain fonts, it looks like it says Apple, A-P-P-L. And I couldn't figure out why Bart was talking about Apple in this. And I finally, I changed the font to something else so that I could see that it was actually app1.
[18:29]Interesting. I wonder what the theme on our actual website, I'm hoping it'll be good we'll.
[18:33]Find out I think our
[18:34]It's bootstrap so it should be good it's usually good I hope so um okay PC app 2 dev.
[18:42]Yeah I talked over you so I want to make sure since I interrupted you we've got the remote repos and then PC app 1 dev and PC app 2 dev those are the two PCs of our newly hired developers
[18:55]And PC brand designer Shotgun to Horror is the PC of the person looking after our brand So we have all of our players here. Personal computer, not Windows. Do you mean computer? Personal computer. Well, the Mac is the first personal computer.
[19:10]But it doesn't have to be a personal computer. Okay, quit niggling, Allison,
[19:17]Let him move on. Let's not go there.
[19:18]Okay.
[19:19]So that's the first thing it does, is it makes those folders. Then there are copies of all the repositories we need safely saved as Git bundles called pbscorp-brand.bundle, pbscorp1.bundle, and those need to be actually turned into real Git repositories for us to play with. So the script expands those into what are called bare repositories sitting on the server. If that confuses you, installment 113 explains that on a Git server, you have a repository with no working copy because otherwise you could break things horribly. So that's why they end in .git. There are Git repositories you can clone, you can push, you can pull, but you can't go into that repository and make a change.
[20:04]It's just it's a server it's not designed to be a pc so that's all that's doing it's just putting those repositories onto our pretend server and then it makes an empty repository that we're going to need for scenario two on the server and it also pre-clones the brand repository into the brand designers pc because we need that in scenario three so we just set everything up for us to do our scenarios. Got it. So the very the first thing you're going to want the first way you're likely to bump into a sub module is by cloning an existing repository that happens to have one. So let's start by doing exactly that. We're going to pretend to be a brand new developer who's just joined the company has been told you familiarize yourself with app one please. So you sit down at your brand new PC, and you need to clone the repository for App1, which has a submodule, the brand. So, initially, so if you'd like to play along, change into the folder PCApp1Dev, so that you're now on the App1Dev's new computer.
[21:12]Okay.
[21:13]And that folder is empty, because that dev hasn't done anything yet. So we want to clone the repository for app1, which is git clone dot dot slash remote repos pbs core dot app1 dot git. Ordinarily, that would be something like https colon slash github dot com, whatever. But look, we're doing all this local, so it's just a file path. So now we've downloaded the repository, and if you open it in the finder, you'll see that, oh yeah, it has an index at HTML, and it has a folder named brand. Let's open index.html on our favorite browser.
[21:49]First thing you'll notice is it doesn't seem to have a brand. It looks like Bootstrap 5 out of the box. Yeah, okay. Exactly what it looks like. And if you open the developer console, there's a giant big error. Fail to load brand forward slash style dot CSS. Could not be found. Well, hang on a second. There's a folder called brand, but there's literally nothing in it. Huh. This is how you tend to discover you have something with submodules, by the way. You tend to discover it by going, well, I've cloned this and it's broken. If it's code that's supposed to compile, it won't compile. If it's a plugin that uses PHP, you'll get PHP errors up the wazoo. Something will not be working and you'll be left scratching your head. So let's pop into our terminal and go into our repository. So CD PBS core app one. And let's do a git status. I'm sure that will tell us exactly what's going on here. Why is this website that I just cloned not working? Well, it says, on branch main, your branch is up to date, nothing to commit, working tree clean. That wasn't very helpful, was it? That tells us everything's fine. But it isn't, because we have an error and the app doesn't look right. Okay, well, there's clues. So, as you note later in the show notes, if you're using a GUI, there'll be more clues. But for us on the terminal, we need to go looking for the clues more proactively. So, the first thing is that everything...
[23:17]Back up. We also, as a web developer, looking at the plain bootstrap web page, we had no way of knowing that was what it was supposed to look like. So we wouldn't have known to even look at the console to see that it hadn't loaded the branding.
[23:39]In the case of a web app like that, where the only thing that breaks is the branding, you're right. In my real-world experience, when I bumped into these things, I had PHP errors, 20 high, scrolling up the screen.
[23:50]Okay, all right.
[23:51]It was like, I've broken my website, is actually what it looked like. Because it was a plug into Moodle, as it happens, and our Moodle went, don't worry, it was the dev site. I don't experiment on production. Oh, no, no. One does not do that. Anyway, so in this case, the error console is the closest I could get to showing an error that a developer could conceivably notice. So we'll have to play along. So every single Git repository that has submodules will have a file called .gitmodules. I wish it was called .git submodules because God knows how many times I made that typo in these show notes. But anyway. It's called git modules and that file is like .gitignore that is a standard file that is used by git to configure itself and so if you view that file by saying cat.gitmodules you will see that it defines a sub module named brand with the folder path brand and the remote url which is not very remote it's a file path because we're we're simulating these things dot dot slash dot slash, So that's telling us that that remote repository should be cloned into that folder. Should be. Not has been. Should be.
[25:12]Is it telling you that it isn't? Just should have been.
[25:17]Well, it's telling you that if you'd like this code to work, it must be. In other words, it's telling you that this repository assumes that it will do this. But you have to actually do it.
[25:27]If it had been pulled in, that submodule had been cloned in here, it would say the same thing.
[25:36]Correct. That is a statement of how this repository is configured.
[25:42]Got it. Okay. All right.
[25:43]It's a configuration file. Yeah. So if we type git submodule status, it tells us that we have a commit ID, which is a giant glob of X always. And that it should be in brand, and it says minus in front of it. And I've only just noticed a minus now. I should update the show notes to draw attention to the minus. The minus means I don't have this, and I should, because that minus will disappear after we actually set things up properly. So what it's saying is this commit should be in that folder, and it isn't.
[26:16]So the minus tells us that. So I'll make that item three here that we should notice.
[26:22]Yes, perfect. Yes, please.
[26:23]Okay.
[26:24]So the first thing to notice is, oh, brand is a submodule because the command git submodule status will only tell you about submodules. So if there were none, it would have just returned straight back to the cursor with literally nothing. So, okay, immediately git submodule status tells us, ah, okay, there is a submodule and it's named brand. And it tells us the idea of the remote commit that it wants. It doesn't have yet because we haven't told it to, but it wants.
[26:48]Is it a correct statement to say the minus before the commit tells us that it hasn't yet been pulled?
[26:55]Yes, it is behind where it should be. Okay. Yeah. So the very, very first thing we have to do actually is to tell, so we have cloned this Git repository. So we now have a local copy of it, and our local copy hasn't yet figured out how it should talk to that sub-module. So you tell it to ingest into its .git folder, which is a joint big database, the facts in the .git modules file by saying git space sub-module space init. And that way we'll read that file and it will go, oh, okay, so I should have a sub-module called brand. Okie dokie. And it says it's that dot, dot, slash, dot, dot, slash. Well, what's that really? Oh, that's slash user slash Allison or slash user slash Bart. It'll figure out the actual path to everything, and it will actually set up the sub-module in its own brain.
[27:53]Okay, so the answer it comes back with is that it blah, blah, blah, registered for path brand. Registered. Is it initialized? Yes.
[28:04]No. So now the brain knows about it. So the config file is sitting beside the .git folder, which is your local database. So now it has incorporated the .git modules file into its hidden .git folder, which is the folder you never, ever, ever, ever touch because that's Git's database. And if you mess with that, Git explodes. So it has now incorporated that human visible thing into a machine visible database that you don't touch.
[28:33]So, git submodule init does not initialize the submodule. It registers that it exists. It tells the git database, hey, there is a submodule over here that we're going to ask you to go get later, but hang on. We're just fixing to make a plan to initialize it. Wow. Yeah. That's unfortunate, but okay.
[28:53]Don't worry. You don't have to do that all the time, right? You do that when you clone the repository. I should say repository. There's another typo. So when you clone the repository, you have to initialize the submodules if it has any. And if later a second submodule were to be added to this repository and you did a git pull and then that second submodule arrived, that would arrive inside the .git submodules folder or file, but it wouldn't yet be in your database. So you'd have to do a git submodule in it again. So it registers the new submodule.
[29:27]I have this feeling that they should change that in the future. Like, if you clone a repo that has a submodule, why not initialize it in your .giv file? Why make people do that manually? There must be some circumstance under which you don't want to.
[29:45]Yes. If, because of some sort of weird network reason, you have to use a different URL for the same module, you're going to fetch the same code, but you have to fetch it differently. Maybe you can't use SSH, you have to use HTTPS. Then you could edit your local copy of the file and then do an init, and then you could work away perfectly after that, but you would be talking to the repository in different ways. So there are edge cases, and they're very on the edge, and they're called out in the official documentation as edge cases. In the unlikely event, you can do this. So I think that may be why they're not completely atomic, but there should be like an option that just says minus, minus, do everything. Yeah, yeah. Minus, minus, do everything.
[30:33]Minus, do it for me. Yeah, I like that.
[30:36]There may even be an option in the very latest version of Git, but the Mac is not very good at getting the very latest version of Git. So maybe that problem is solved and I haven't come across it yet. So now our local Git repository knows everything it needs to know and it's ready to actually check or pull that specific commit from that specific URL. So to actually go and fetch the actual information from the remote repository, we're now ready to do that with git space submodule space update.
[31:09]Okay. Wait a minute. I pasted that in and it says fatal transport file not allowed. Did we forget to put our git minus c protocol dot file dot allowed dot equals always in BART?
[31:20]Well, forget is an interesting word. I left it out on purpose so you could walk into the error. Yes.
[31:25]Okay. so remember when you see that that's probably because you're talking about uh going to these uh relative urls right
[31:33]These file paths exactly correct they don't have to be relative it's just a file path instead of http or https an early draft of the show notes had that wrong which is why it's wrong in your head i'm positive.
[31:45]That's why i said it wrong
[31:46]Oh totally completely um So, and now you'll see cloning into, and it tells us, yay, submodule path brand checked out, and it tells us the commit that we had before in our git submodule status.
[32:03]Yeah, and there's no minus on it.
[32:06]And there's no minus on it anymore because it has now been checked out. So it's now, okay, this is in sync. So I said I wanted that folder to have this check out, and it does. This commit checked out, and it does. Yay. Great. We are good. So if you reload index.html, it's now, well, it's branded. I won't say it's branded well, but it's branded.
[32:29]Okay, yeah, yeah, it looks like something.
[32:33]Exactly. I kind of made sure it looked notably different. Some silly Google fonts and some silly colors.
[32:39]
Cloning a Repository with Submodules
[32:40]Okay, so that's our first and very realistic scenario, cloning a repository with a submodule. And if you had many submodules, this would have worked just the same.
[32:50]Okay, so let me review. So this was a new developer into App1. They cloned the repo. They didn't get the branding. They figured it out by, not by git status, but you could see it in the console on the display. But then we did something in here. Oh, our git submodule status, and we could look into the config file and see it into the git modules file and see that we were supposed to have branding. And then we did the git submodule init, which doesn't fix it, but then we did the update and it did.
[33:29]Correct.
[33:30]Correct.
[33:33]Okay, so now let's look at scenario two. That's scenario one, simply cloning someone else's code that has a sub-module. So the second most likely thing you're going to need to do is to actually add
[33:46]
Adding a Submodule to Your Project
[33:44]one to something of your own. So you're working on an app and you decide, I want to pull in that code that Bob has been working on. It's great code. I just want to pull that into my app, but I don't want to reinvent the wheel or anything. So let's use a sub-module for that. so we're going to simulate that scenario by saying that we are a developer who has just been told, you have to start app one so you get to build an initial version of app one and app one you know you make it do something and then you're going to have to connect it to the brand so you're going to have to add a sub module you.
[34:17]Just said app one we're talking about app two now just to be clear
[34:19]Yes we are okay yeah sorry i always do these things you've no idea how often i fix that in the show notes. So if you change into the PCapp2dev folder, and then you will find that is completely empty. But our init script created a repository waiting for us to clone it. That repository is empty, but it is sitting on the server waiting for us to clone it. So we can say git clone dot dot slash remote repos PBS core app 2 dot git. And when it clones, it'll actually tell us, warning, you appear to have cloned an empty repository. Yeah. I did.
[34:56]Yeah, okay.
[34:59]So if we change into that repository now, so cd pbs core up to. We are going to create an initial version of our app by copying the one I made earlier, sitting a few levels down in the zip file. So the command to copy that file into index.html is sitting there.
[35:18]Okay.
[35:20]So now I've got a nice little index.html.
[35:23]But I bet it's not going to have any branding, is it, Bart?
[35:26]Correct. If you want to open it up there, you'll see that it has, it's a silly little web app, and I was getting into the spirit for Christmas. It is a countdown to the next Christmas, and it will be right every year.
[35:38]It's seconds to Christmas. Seconds. 2.7 million. I can't wait that long.
[35:44]I know. It's forever. So, okay. So we now have our first version of our app, but it's not branded yet. But anyway, let's commit it. Let's get this committed. So git add index at HTML, git commit minus m, feat initial implementation, git push. Okay, great. we've now safely saved our work before we go messing around with our first ever submodule. Let's get this safe. Commit early and commit often, as someone would say. Hi, Alma.
[36:13]Thank you, Alma.
[36:15]Okay, so to add a submodule, you won't be surprised to find that the command is git submodule add. This is very clever. At the very, very, very, very, very least, you need to tell it where to go fetch the code from. So a URL is the required argument.
[36:34]So hang on. As app developer two, I know I've been working here for ages. I know we have branding. I know that I have to go get that sub-module, correct?
[36:44]Correct. Okay. Yes, and as a developer, you're always going to be adding it because you want to, right? You're going to have a reason to want to add a sub-module. That reason will be different depending on the real-world scenario. But yes, in this case, the developer here has been told you need to bring the brand in, and you know that you do that with a sub-module because we don't duplicate the brand. We copy it insensibly because we're an organized company here. So you always have to give it a URL to clone from, and you can optionally give it a second argument, which is the actual folder you'd like it cloned into if you run it without giving it a folder it will take the name of the repository without its.git on the end and use that as a folder name so for us that would mean it would use the folder name pbs core dash brand but i don't want it to be called pbs core dash brand i want it to be called brand so i do give it a second argument the second argument i give it is in fact the name of the folder i really want which is brand so for us there's going to be a two argument so git submodule add the relative path to our our brand and then the folder we want brand you.
[37:52]Skipped a section you talked about yeah right after you explained that has the url you start talking about looking for the repo
[38:01]Right okay so before we yeah i want to show you a before and an after so once we actually add our submodule that's going to have an effect on our local repository here. So before we do it, I want to show you what it looks like when there are no submodules. You kind of know it already because that's how every module is looked or every repository is looked since we started doing Git. But let's just prove it to ourselves. Try to show the current contents of the .git modules file. There's another typo. And it will say there's no such file or directory. And if you type git submodule, it will go straight back to your cursor. It will just, no, I don't know what you're talking about. No submodules here.
[38:48]Okay.
[38:49]It's not an error. You've asked it to list all of nothing and it's gone, okay, here's nothing. Good day.
[38:55]All right. I'm trying to make sure I got the typo right. It should be cat.gitmodules.
[39:00]Yes, because remember I said I wish they'd named that pretty file submodules.
[39:04]Yeah, and it's plural, which is interesting, because all the other times we say git, it's module.
[39:12]Well, you can have as many as you like, right? Right. Yeah. Anyway. Okay, so that proves that we don't have one yet. So now we're going to add it with git submodule add url to repository space name a folder. And that's going to fail because we're using relative file paths. And the git submodule add does a second thing, it will actually clone the repository for us. It will add and clone, and that second and clone will fail if we don't do it with the minus C protocol file allow a voice.
[39:44]Because we had a path. Okay.
[39:46]Because we had a path. So you'll see immediately the folder gets added and immediately we get our clone. So this is it being helpful. This is how we wish the original clone would have worked actually.
[39:56]Right.
[39:57]But it's very helpfully gone and done it all correctly. So now if we look for the file named git modules, and this time it's right in the show notes. Oh, look, it now has the submodule named brand with the path brand and the URL, whatever it is. And if we run the git submodule command, it shows us our submodule without a minus because, hey, I've already cloned it. We're all good here. No changes.
[40:20]Okay. Okay.
[40:22]So now we can see if we look at the content of the brand folder, it has the style.css file that we need. But we haven't actually added it into... Oh, sorry. Yeah, okay. Sorry, my show notes have my slightly confused. If we do a git status, by the way, let's just catch... We're not going to do any more changes other than just add the submodule because I want to show you what the git status looks like now. So the git status, before we do any more work, tells us there's a new file, the git modules file, and it tells us there's a new file named brand. Now, notice it refers to the entire submodule as a single unit named brand. It doesn't tell us what's in there because all it's actually saving in its database is the URL to clone from and the number of the commit. That's what's actually saved is the id of the commit so that commit could contain a million files but as far as our database is concerned all we save is this is the commit i want so we're not duplicating all of that code in the brand repository we're just saying which one should be checked out oh.
[41:36]That's really interesting okay
[41:38]So it's kind of like a sim link or like a a shortcut in the finder not in the shortcuts app oh that word has become overloaded, and when we change things all that's going to do is change which commit should be in that folder it's not going to it's not going to save as changes all those millions of changes it's just going to save the new hash so it's very sensibly inefficient you're linking to the hash sitting on that other remote repository okay so now we can actually use the style.css by adding it into the top of our HTML file, it would just be the single line link rel equals stylesheet href equals dot slash brand style dot CSS. But to save you the bother, I've saved a copy of the HTML file with that already in place that you can just copy and paste over the current one using the cp command in the show notes.
[42:30]Okey dokey.
[42:33]So now when we do a git status, we still see that we have our new sub module and we see that we have modified index.html.
[42:43]Ah, yes.
[42:46]So now, A, if you refresh in your browser, you can see that we have our brand, but B, we're now ready to commit our changes. So git commit minus am feat incorporate the corporate branding using a submodule. Git push.
[43:03]Got it okay i'm playing along and it's working it's doing everything you're seeing
[43:09]So that's two very common scenarios beginning to basically i call it consuming someone else's code with the sub module right i want the brand in my project i'm going to consume it from their git repository so now let's look at what happens over time so great i have consumed the brand into my two apps and now the brand designer has decided that oh we need to modernize our brand or fix a bug whatever right and that means that our two developers are going to have to in a controlled way bring that change into their versions of i know into their apps right they're bringing that code in in a controlled way that's the whole point of this so we're going to step through that process by becoming we're going to wear three hats not at the same time first we're going to start with the brand designers hat they're just going to update the brand and then Then we're going to put on the hat of app developer one, and we're going to take that change from the brand into our app.
[44:09]
Updating the Brand from the Designer
[44:05]And then we're going on the hat of app developer two and take that change and bring it into our app. And you might say, Bart, that sounds like you're making me do the same thing twice. And we've already been recording for an hour. Why are you making me do the same thing twice?
[44:18]And the version of the show notes you proofread didn't make you do the same thing twice. So you're now looking very confused at me. But this is my morning's work here. So, there are actually two completely different ways of interacting with submodules, and I think of them as the inside-out and the outside-in. So you can work with the submodules from the point of view of the outer module and never leave the outer module. You can do everything from the outer module and sort of command the submodules to do things. That makes sense. Or you can change into the submodule with a CD, at which point you're in a Git repository. Okay. And then you can do everything you need to do using only the Git commands we have known all along.
[45:01]Fetch, status, pull, push, commit. Nothing more, and you can work with submodules. But then you have to CD into the folder and work in there. So both are perfectly valid. If you do it from the outside in, you can update a thousand submodules in one command. And so if you always want all the changes from everywhere, that makes sense. In my real-world experience, I'm way more picky. I want to update a specific plugin. So I go into the sub-module for that specific plugin, I interact with it, and then I step back and I commit the fact that there's now a new hash.
[45:44]Okay. So this is, in my world, sort of like going into the app store and saying, I would like to manually update my apps. I go in and I see there's 37, and I say, I'm going to do this one, this one, this one, but I don't want to do Xcode right now because it's going to take an hour and a half because it's so big. Or that's dangerous to what I'm trying to work on right now. I don't want to do that one. So this would allow you that control.
[46:07]It would. And sometimes what you want to do is test a plugin you're very nervous about. Yeah. And so you're going to do it, just this one, please? Surgically. Yeah.
[46:16]Yeah.
[46:16]Surgically, as you would say, a good engineer, change one thing at a time. So we're going to do it both ways. Okay. Yeah. So step one is the easy part. We're going to be brand design and update our person. So we're going to change into the folder for PC brand designer, where we will find the repository for our brand. So change into that as well. So you're now going to be in PC Brand Designer slash PBS Corp brand. So you're now in the Git repository. So this is a clone from the company's Git server of the repository that holds the brand. So this is our normal life. This is a Git repository like these show notes. This is a normal Git repository that we've cloned from a server. So all we do is we change our style sheet. The change we're going to make is a little arbitrary, but I had to do something. At the moment all six of our h tags are blue i would like them to alternate so h1 three and five get to stay blue but two four and six are going to become green so i could show you the css code but we've done that all so you can copy my updated version of the file over a style.css in this repository with the command in the show notes and all it's doing is changing the css in style.css.
[47:33]I'm afraid that command breaks.
[47:38]Are you in the right folder?
[47:40]I'm in pc-branddesigner.
[47:44]You didn't go into the repository.
[47:46]Ah, there we go. Sorry. Gotcha. Good. All right. That worked.
[47:55]Good. Okay. So we've now changed our brand. So if you do a git status, it'll say, hey, look, you've modified style.css.
[48:03]Look at that.
[48:04]So this is just like you fixing my typos. You have a lot of those today. So what do we do? Well, we go git commit minus am feat altering heading colors or alternate heading colors. Git push.
[48:17]Okay. Right.
[48:19]Completely normal. This is what we do in Git. This is what we learned all the time, right? So the brand designer, he's just, or she, they, them, they've done their thing. So now app developer 1 is going to consume that change from the outside in. They're going to only work from their outer repository. They're never going to step into the submodule. They're going to stay in the outer module and do a repository and do it all from there. So we're going to change into PC app1 devs folder and then into the repository for PC core app1. So app1.dev slash pccrop1. And if you do a Git status, you might have assumed, oh, this is going to tell us that there's a new version of the brand we could choose to bring in, but no.
[49:07]But no. No, no, no. Why would it do it now if it didn't do it at the beginning, right?
[49:12]Exactly. So it says, oh, you're on branch main, you're in line with origin, and there's nothing to commit. Good for you. Okay. Well, let's do a Git fetch, but tell it to fetch everything. So this is one of those secret commands so git fetch minus minus recurse minus submodules what do you call it and instead of only asking well okay not a trick hidden not obvious yeah not not obvious something we haven't learned before something you need to go read the manual for okay speaking from experience and now we can see it says oh look there's a there's a new commit you know, you're seeing it consume something. Oh, look, there's a new commit there on Origin Main inside PC Core Brand.
[49:58]Hmm.
[50:00]It says fetching sub-module brand, and it says, oh, look, there's a new commit on main.
[50:05]Yeah, git status still says, nope, you're all good. You got nothing to do.
[50:09]Right. Because from the point of view of the parent module, or the outer module, nothing has changed yet. You haven't actually, you've done a fetch.
[50:17]Yeah, not a pull.
[50:18]You haven't done a pull.
[50:19]Okay.
[50:20]So how do we do a pull? Well, we actually don't have to do a pull because we're in the outer, we're doing the outside in. So actually we can use the git submodule command to just update all the submodules all of them, just get all of their latest versions we didn't, you know whatever's behind what it could be you've just done the fetch, you know what's behind so you can just say.
[50:42]
Consuming Updates from Submodules
[50:43]So we did git fetch minus minus recurse dash submodules and that pulled all of the possible change it didn't pull, it fetched the changes so that it knows what's out there so any submodule I had, it now knows about it and when i do a get with the always allow thing submodule update minus minus remote that's saying now i want you to actually update all those submodules so you don't use pull because we're outside
[51:09]Correct we're the outside in so we're telling the submodules oh just update yourself okay under the hood there's absolutely a pull happening which is why we have to use the minus c to tell it that we're okay with it pulling from a file because it's our git submodule command is actually causing git pull commands it could be causing hundreds of them if you have lots of submodules but it's just we're doing it from the outside in so we're just saying dear submodules update yourselves go get you know what the latest version is make it make it so okay right right and so when you do that you will see submodule path brand checked out and we have a different hash ends in 8355 because it's a whole new commit it has a different hash, And if we open our app now in our browser, now the H2 is a different color to the H1. We have a blue heading and a green heading.
[52:03]Hmm. I'm supposed to be in PBS core app two, right?
[52:08]No, app one. We haven't done app two yet. We're in the folder for app one.
[52:12]Sorry. I had the app one. Okay. Let me go back to that one. Refresh it. Here we go. Oh, look at that. The second heading is green. Still a silly font, but it's working.
[52:21]Very exciting. Okay. Got it. Yes. Very exciting. Okay. So we have now made some sort of a change in our outer module and we're doing it from the outside in. So everything from our, we're working entirely in the outer module. So if we do a git status, what does the outer module now think? The outer module thinks there is one change. You have checked out a different commit on your submodule brand. So it says modified brand, new commits.
[52:48]Okay.
[52:51]So we want to push that. So we just say git commit minus am feat updated brand git push. And now that new, hash is now been pushed up to the server as the one the next person to clone or the next person to pull should have.
[53:13]Okay got it got it
[53:17]So that's the outside in and that worked for one submodule and it would work for a hundred submodules all at the same time that's.
[53:24]The way I get to do it That makes sense to me. But all right, we're going to go inside and do it next, right?
[53:32]Well, there's a reason you like scenario 3C, because it means you don't have to learn any new commands. This is how I do all of my submodule stuff, because I don't have to remember anything. I just do what I know how to do anyway.
[53:43]Okay.
[53:44]I'm very lazy.
[53:45]You're selling it.
[53:46]So I'm selling it. So now we're going to app 2. So make sure you're in the folder PC app 2, PC core app 2. And because we're going to work from the inside out go into the brand folder go into the submodule.
[54:03]Go in as in cd
[54:05]Cd into the brand yeah because we're doing it inside out so go right into that git module all right and if you do a git status initially right now it says your brand is up to date with origin slash main oh that's weird well remember we're on the command line you and i have gotten way too used to shiny GUIs. Every time you look at a GUI, it does a fetch for you behind your back.
[54:30]Oh, right, right, right.
[54:31]That's why it's always showing you the stuff you can pull. But we're on the terminal. So we've got to go git space fetch. OK. We don't have to do any fancy commands. We don't have to remember city flags, because we're inside. So we just do a git fetch. And now, if we do a git status, it says, oh, you're behind by one commit. OK, well, what do we do if we were writing the show notes? Git pull.
[54:52]Right.
[54:54]Now, of course, we could just walk into that folder and do a git pull without doing a fetch first, because when you do a pull, it does a fetch. But then we wouldn't know in advance what we were getting, which, to be honest, when I get to the show notes that you've edited, I don't have to look at them first. I just pull without looking. So maybe that's what you want to do. But anyway, to see what we're doing, we've done a fetch and then a pull.
[55:13]Right, right.
[55:14]So we are now, we have, sorry, we just successfully, that's it, right? So on the inside, we have now successfully gotten our change. Okay but we are in a module in a module or sorry we are in a repository in a repository so let's cd dot dot and let's now look at the universe from the point of view of the outer repository, so if we cd dot dot and then we do git status well actually what it shows us is exactly what it showed us after we did the outside in commands it says modified brand new commits yeah because the hash has changed yeah and it needs to commit to its outer self that the hash has changed so So git commit minus am, feat, update brand, git push.
[55:56]Yeah. Ooh, you used past tense, Bart. I'm changing it. Oh, sugar. Update brand, you know. Yeah, do. That's such a weird thing. I know. I always want to think of it in past tense, but we made a rule that we were going to follow the guidelines, which are its present tense. Update brand.
[56:14]Yes, it's the imperative. What are you doing?
[56:17]Yeah. You're right. I like 3C. I like that better. I don't have to remember all those other commands. I just go in. And to be honest, I am the kind of person who updates every app manually and glances, at least for the apps I care, glances at the notes to see what it is.
[56:35]Well, I want to know what the cool shiny is. If it updates it automatically, I won't know what features to go look for. Because if I read the release notes, I know what's cool, right? I don't read them all, but some of the apps I do. Yes, please.
[56:48]All right. So I asked Bart after reading the show notes and going through this once, so this is all well and good on the command line, but how would I know if there were submodules when I was using a GUI? And he said, look at the GUI. Oh, fine, Bart. And so I opened up the show notes in, I'm sorry, I opened up these repos in two different apps. I've started playing around with something called GitFox, which you can get from Setapp. And I also put in GitKraken, which is the one I'm actually used to using because it's what BART uses. And on both of them, in the left sidebar, there's a thing that says Submodules and under it you can see Brand. So that's how I knew that there was a submodule. They did a little bit differently. GitKraken actually tells you how many submodules are there and a little number and then it's got a little up arrow if you're working on it. But I got a little leaf on submodules on GitFox, which I thought was cute since we talk about branches. This is a leaf.
[57:48]Yes. It is actually very cute, yeah.
[57:52]Yeah. I enjoyed this part. This was fun, and I think you set up some really good examples. I know they're contrived and everything, but I didn't really get into programming by stealth until I could see what it does. So seeing the branding changes, seeing the color changes, that mattered to me. That made me go, oh, I see what I did. I changed this, that changed, and then this happened. I need the visual. I'm that kind of a person. So I really like this lesson.
[58:17]I remember the apps are silly and the brand is silly, but the process is identical to a real app getting a real new brand that's actually done with care, right? The scenario is realistic, even if our actual code is very silly.
[58:33]So that sets us up for a part two. So there is something that is in common with all of our examples today. We have been the passive receivers of other people's code. We have consumed the brand, and that's very helpful. And that's how in my real world I use submodules almost all the time, is to passively consume plugins to things and so forth. So that's already very powerful. But you don't have to be passive inside the submodule, it is a git repository. So we have already seen that we can go in and do a git fetch and a git pull.
[59:15]
Exploring Push and Pull in Submodules
[59:16]It's not a million miles of a shock to tell you that you can also do a git commit and a git push, inside the submodule to send changes up the other way and that opens up a whole avenue of very powerful things and so that's the first of our scenarios next time is app 2's developer has decided that they want to expand the branding they want to add some support for something the brand doesn't currently have. And they're going to do that work inside app two, prove it works, and then they're going to push it up to the brand.
[59:51]All right.
[59:52]And then, so that's our first of our important scenarios. And the second thing we haven't yet looked at is the fact that the entire sub module is saved as a hash. And it pretends it's a file with that hash. So if we make a branch, we can have that same sub-module be linked to a different hash. So you can have a dev branch of your outer repo that is talking to an old version or a new version of the brand, a test version of the brand, while the main branch of your outer module or your outer repository is still linked to the production branch of the brand. So you can do a lockstep. Let me test this change in a controlled way by messing with branches with submodules. So that's scenario five.
[1:00:45]All right. Well, this sounds fun. I'm excited. This is cool. I really enjoyed this episode. This was a lot of fun.
[1:00:56]Okie dokie. Well, until next time, remember, folks, happy computing.
[1:01:00]If you learn as much from Bart each week as I do, I'd like you to go over to lets-talk.ie and press one of the buttons over there to help support him. He does 98% of the work here. I'm just the stooge that listens to him and asks the dumb questions. If you go over to lets-talk.ie, you can support him on Patreon, you can donate via PayPal, or you can use one of his referrals.
[1:01:24]Music