Recent Entries 2
- snippet tip 120d agoAn introductory guide to Git submodulesGit submodules are a powerful feature that allow you to **include other repositories within your own repository**. This can be useful for including libraries or other code that you want to keep separate from your main repository. To add a submodule to your repository, you can use `git submodule add <upstream-path> <local-path>`. The first argument is the **URL of the repository** you want to add as a submodule, and the second argument is the **path** where you want the submodule to be located within your repository. Adding a submodule will create a **new directory** in your repository that contains the contents of the submodule repository. The submodule directory will contain a `.git` directory that points to the submodule repository, allowing you to **track changes** to the submodule independently of your main repository. Additionally, a `.gitmodules` file will be created in the root of your repository that contains information about the submodule, such as the URL of the submodule repository and the path where the submodule is located. After adding a submodule to your repository, you will need to **initialize and update** the submodule to fetch its contents. You can do this by running `git submodule update --init --recursive`.
- gotcha major 124d agoGit submodules: initialization and update gotchasAfter cloning a repo with submodules, the submodule directories are empty. After a teammate adds a new submodule, existing clones don't get the submodule content automatically.