How to update a submodule in git to commit HEAD in this external repo

I had problems finding the answer to this question, so I am sending it to posterity.

The situation is that you have a git repository with a submodule (similar to svn external). You want to update this link to point to a different commit in the external repository. You might think: "git subodule sync" or "git submodule update" will do this - you're wrong.

+4
source share
2 answers

Steps:

  • cd to the actual directory in which the submodule is located.
  • run 'git pull origin' or whatever you want to do to set it to a new commit.
  • cd from this directory (presumably to the root of the repository) and run "git status" - you will see that the directory is changed. If you run diff, you will see something like this:
  diff --git a / default / bin / hdvcs b / default / bin / hdvcs
 index bbd3f56..7c9394c 160000
 --- a / default / bin / hdvcs
 +++ b / default / bin / hdvcs
 @@ -1 +1 @@
 -Subproject commit bbd3f56898054e533e81b52b90b94155841b40a8
 + Subproject commit 7c9394c8520e41a704e6658360064758b20a3dfc
  • commit this change.
+4
source

If you want to update all your git submodules in the HEAD of the remote repo, just type

git submodule foreach git traction creation wizard

+1
source

Source: https://habr.com/ru/post/1301514/


All Articles