

This is common when you are experimenting with different checked out branches or tags in the submodule and you want to restore it back to the commit tracked by the parent repository.
#Git submodule get update
The git submodule init and update commands are needed to pull down submodule artifacts and resources. Run it by using the syntax below: git submodule init - path1 path2. The list of steps required to clone a Git repository with submodules is: Issue a git clone command on the parent repository. Performing a submodule update is also useful when you want to restore your submodule’s repository to the current commit tracked by the parent repository. Pull the Latest Submodule with git fetch and git merge. git submodule init is a straightforward command that performs a single path recording task. This was done to make it less likely we will get accidental commits on the. They can clone from GitLab, they can do a Git submodule add from GitHub or they can manually create all their repositories and submodules. You may also note that the URLs used for the submodules use the old git:// protocol.

When you do the commit, the index will update the commit string for the submodule. The git submodule add example There are several ways a developer can add Git submodules to an existing repository. You would then fetch the latest changes in the submodule’s Git repository and perform a submodule update to check out the current revision referenced in the parent repository. Simply add the path to be commit and do a commit. You commonly perform this task after you pull a change in the parent repository that updates the revision checked out in the submodule. Performing a submodule update checks out that specific revision in the submodule’s Git repository. A Git submodule allows you to integrate other Git projects into your code, without the need to copy-paste all their code. In this case the Git parent repository tracks the commit that should be checked out in each configured submodule. Submodules are Git repositories nested inside a parent Git repository at a specific path in the parent repositorys working directory.

Alternatively to the tracking of a branch, you can also control which commit of the submodule should be used.
