How to update git submodule to a specific commit?

Viewed 2371
git submodule update --remote

Above command updates the submodule to latest commit however I want to update to a specific commit (e.g. to some commit hash). How to achieve that ?

1 Answers

git submodules are repositories inside a repository, hence it has the same behavior as any other git repository. Hence enter the dependency root by using cd submodule and use any git command.

cd submodule
git checkout -b NEW_BRANCH_NAME COMMIT_ID
Related