3

I want to add a check to my cmake script that checks if the head of the remote submodule repository has been updated. Up until now I just ran git submodule update --init --recursive in the script, however this could end up in unexpected changes if the remote submodule is updated. Is there a nice way to check if the remote head is a few commits in front of the local submodule's head without changing the state of the local submodule?

TheCharlatan
  • 288
  • 3
  • 17

1 Answers1

2

Based on https://stackoverflow.com/a/3278427/7976758 I'd do something like this:

git submodule foreach git remote update
git submodule foreach git --no-pager diff origin/master master

If submodules use different branches the script needs to take that into account.

phd
  • 82,685
  • 13
  • 120
  • 165