Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

History/blame git submodule

Tags:

git

I have a project A that uses project B as a git submodule:

A
└── B

I want to find which commit in A updated the current ref for B. The A/.gitmodules file only contains the remote, not the ref. And running this does not work:

git blame -- B
fatal: no such path 'B' in HEAD

How can I find the commit in A that changed which commit of B to check out?

like image 491
z0r Avatar asked Nov 16 '16 04:11

z0r


People also ask

How do you fix a dirty submodule?

You can fix it by: either committing or undoing the changes/evolutions within each of your submodules, before going back to the parent repo (where the diff shouldn't report "dirty" files anymore). To undo all changes to your submodule just cd into the root directory of your submodule and do git checkout .

Does git blame shows the lines that were deleted or replaced?

The report does not tell you anything about lines which have been deleted or replaced; you need to use a tool such as git diff or the "pickaxe" interface briefly mentioned in the following paragraph.

How do I see my git history?

On GitHub.com, you can access your project history by selecting the commit button from the code tab on your project. Locally, you can use git log . The git log command enables you to display a list of all of the commits on your current branch. By default, the git log command presents a lot of information all at once.

Are git submodules a good idea?

Git submodules may look powerful or cool upfront, but for all the reasons above it is a bad idea to share code using submodules, especially when the code changes frequently. It will be much worse when you have more and more developers working on the same repos.


1 Answers

You can see the history using git log:

git log -- B
commit 469e844f71d60f862e14e64302dbc849cbc7ba51

Or to see a summary of all the changed commits:

git log --patch-with-stat -- B | grep commit
commit 469e844f71d60f862e14e64302dbc849cbc7ba51
-Subproject commit a677c5ccb01071c6cfe5a6de9bddcd43ad5198ca
+Subproject commit 02ec5cb265a744f0a8a710920f0e2a832cc433f2

The first line is the commit in project A, while the other lines show how project B has changed.

like image 91
z0r Avatar answered Sep 19 '22 12:09

z0r