问题
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?
回答1:
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.
回答2:
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.
来源:https://stackoverflow.com/questions/37064338/whats-the-git-command-to-determine-which-commit-changed-a-submodule-pointer