Skip to content

Add beginner guide to Git submodules #1

@Smartyguy001

Description

@Smartyguy001

Such a guide can be helpful to beginners and can make contributing seem friendlier and easier.
I will now write a draft of such a guide, should it be useful to anyone fixing this issue.


HOW TO work with a SUBMODULE project, on a simple level, with GITHUB DESKTOP (GHD)

1. CLONING

The only command for which you actually need a CLI
The command is:

git clone --recurse-submodules

Then you can use "Add existing repository" in GHD

2. FETCHING + PULLING

Automatically done with --recurse-submodules
No extra work required; just go in the main repository in GHD and fetch/pull

3. ACCESSING A SUBMODULE

After you cloned / pulled the main repo (recursively), you can go in GHD to "Add existing repository" and find the submodule folder, located inside the main repo's folder. That folder is the submodule repo, add it. Then, you can work inside it as normally

4a. PUSHING SUBMODULE CHANGES

While you are in the submodule repo in GHD (not the main repo), push the changes. Remotely, the submodule will be updated. Locally, the main repo will be now pointing to the new submodule.

Ah, but the remote main repo doesn't point to the updated submodule! Help!

For this, we have point 4b:

4b. PUSHING MAIN REPO CHANGES (and submodule pointers)

Go in the main repo in GHD and... push! Yeah, that's it!

TL;DR

Wanna clone everything? CLI: git clone --recurse-submodules
Wanna fetch/pull everything? Fetch/pull from the main repo
Wanna push everything? Push everything in the submodule(s) you worked on, then in the parent repo

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions