Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the Git command to determine which commit changed a submodule pointer?

I'm dissecting a series of changes made to a git repo, some of which involved a submodule. I used git blame to find the relevant commit within the submodule, but is there a simple way to locate which commit in my main repo changed the submodule pointer to that commit?

Cue simple diagram:

1 <- 2 <- 3 <- 4 <- 5    (Main chain of commits)
|    |    |    |    |
1    1    1    2    2    (Submodule)

I have located the commit where submodule #1 changed into submodule #2 (say it's 9d95812e...). How do I determine the fact that main-commit #4 is where the new submodule commit was first employed?

like image 684
Matt Mc Avatar asked May 06 '16 04:05

Matt Mc


2 Answers

You can also use

git log -p -- path/to/submodule

to see all commits that have updated your submodule pointer if you want to see how it changed over time.

like image 153
cb2 Avatar answered Oct 19 '22 22:10

cb2


From what I can tell this isn't quite possible, the closest you can get is to determine which commits added or removed that particular submodule pointer:

git log -p -S "Subproject commit c4965b1..."

yields:

commit xyz123456
Author:
Date:

    Message

diff...
@@ -1 +1 @@
-Subproject commit 901231290321
+Subproject commit 1902u8129039

The only thing is +/- are not part of the actual string you're searching for, so you can't look for an addition or removal specifically, but using the -p flag will let you see this easily.

like image 26
Matt Mc Avatar answered Oct 20 '22 00:10

Matt Mc