Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 540
M_nik B Avatar asked Feb 25 '26 03:02

M_nik B


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
like image 199
Abdullah Khilji Avatar answered Feb 26 '26 15:02

Abdullah Khilji