DEV Community

Deepak Sharma
Deepak Sharma

Posted on

How to Update a Git Submodule to a New Commit?

Updating a Git submodule to the latest commit point (the latest version of the submodule repository) is straightforward.

Go inside the submodule folder.
cd path/to/submodule

Pull the latest changes (or checkout a specific commit)

git pull origin main

or

git checkout <commit-hash>

Example:

git checkout 8fd91c2

This will update your repo on that commit or branch. Prefer to use the commit point.

Go back to the parent repo

cd ../../

Add the updated submodule reference

git add path/to/submodule

Commit the updated submodule “pointer”

git commit -m “Updated submodule to latest commit”

Push the update

git push

What Actually Happens?

A submodule stores only a commit reference to another repository.
So when you:

  • Pull/update inside the submodule
  • Then commit in the parent repo

…you are updating which commit the parent repo points to.

Contact for More Information

If you need further clarification or assistance with Grafana customization, feel free to connect with me on LinkedIn.

I would be happy to discuss this topic in more detail or help with implementation.

LinkedIn: (https://www.linkedin.com/in/dipu--developer) (Deepak Sharma)

Top comments (0)