15

I have a couple of submodules and I only want to update one of them.

I think this command updates all of them in .gitmodules

git submodule update --init --recursive --remote

I just want one of the modules updated though.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
Thomas Mccaffery
  • 325
  • 2
  • 3
  • 10
  • Do you want to update a submodule to the latest commit? See here: https://stackoverflow.com/questions/5828324/update-git-submodule-to-latest-commit-on-origin – Tim Biegeleisen Jul 22 '17 at 06:20

1 Answers1

24

The git submodule update command takes a path as a parameter.

Use the path of the submodule you want to update, as said path is recorded in your .gitmodules.

git submodule update --init --remote a/submodule/path

Make sure:

For a manual update, you also can go into the submodule folder, and do a git checkout aBranch/git pull yourself. Then go back to the parent repo, add and commit the new gitlink SHA1 for that submodule.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • "error: pathspec 'a/submodule/path' did not match any file(s) known to git". This answer misses an important detail: this command must be run in the directory where `.gitmodules` lives, not where the submodules themselves are located. – MSalters Nov 14 '22 at 14:02
  • @MSalters Thank you for the feedback, good point. I have edited the answer accordingly. – VonC Nov 14 '22 at 15:40