Search code examples
gitgit-submodules

How to update git submodule to a specific commit?


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 ?


Solution

  • 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