How to `git add path/to/submodule` but with a specific submodule hash?

40 views Asked by At

How to perform git add path/to/submodule but in a way that will update the staging area to have the submodule set to a specific submodule hash instead of the currently checked out hash?

This would be very useful for me when splitting a bulk of changes into separate PRs.

1

There are 1 answers

0
phd On

You need to checkout that commit in the submodule and then commit it in the superproject:

cd path/to/submodule
git checkout $COMMIT_HASH
cd ../back/to/superproject
git add path/to/submodule
git commit -m "Update submodule"