

- #Git submodule point to branch update
- #Git submodule point to branch software
- #Git submodule point to branch code
- #Git submodule point to branch download
However, it probably helps you to understand that the internal maintenance of Git submodules is quite complex. git/modules folder.Īll of these are technical details you don’t have to remember. git/config, which now ends like this: Īnd finally, Git also keeps a copy of each submodule’s. gitmodules file is one of multiple places where Git keeps track of the submodules in our project. gitmodules file has been created in the root folder of our main project. The submodule, however, makes sure that the library files don’t “leak” into our main project’s repository. The crucial difference is indeed that they are contained in their own Git repository! Had we just downloaded some files, thrown them into our project and then committed them - like the other files in our project - they would have been part of the same Git repository. After all, the third-party library’s files are here, just like they would be if we had copy-pasted them.

“So what’s the difference?” you might ask. Resolving deltas: 100% ( 5159/5159 ), done.Īnd if we take a look at our working copy folder, we can see that the library files have in fact arrived in our project. When we run this command, Git starts cloning the repository into our project, as a submodule: Cloning into 'carparts-website/lib/spacetime'. Let’s say we need a little “timezone converter” JavaScript library: $ git submodule add
#Git submodule point to branch code
Now we’re ready to pump some third-party code into our project - but in an orderly fashion, using submodules. Before we go get any code, it makes sense to create a separate folder where things like these can have a home: $ mkdir lib

Let’s take the classic example and say we’d like to add a third-party library to our project. Maybe you just want to share your own code between two projects - a situation where submodules might offer the simplest possible workflow.
#Git submodule point to branch software
The general rule in software development to “keep separate things separate” exists for a reason.
#Git submodule point to branch update

The line between your own project and that of someone else (the library) starts to get blurry.
#Git submodule point to branch download
When you need to include third-party code (such as an open-source library) you can of course go the easy way: just download the code from GitHub and dump it somewhere into your project. To make clear why Git’s submodules are indeed an invaluable structure, let’s look at a case without submodules.
