0

I want to know the commit when a specific submodule was added, in other words I want to know the commit where .gitmodules file is modified to add the following

[submodule "submodule1"]
        path = submodule1
        url = git@bitbucket.org:{user}/submodule1.git

I used the following to get the all commits for .gitmodules

$ git log -p --follow .gitmodules
commit commit#
Author: auther
Date:   Date

    Description

diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..84a18f8
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "submodule1"]
+       path = submodule1
+       url = git@bitbucket.org:{user}/submodule1.git

in this case there is only one commit, but if there is other commits that is adding/deleting other submodules, how can i filter the commits to get the only the commit in which submodule1 was added

Thanks

Mahmoud Adam
  • 5,772
  • 5
  • 41
  • 62

1 Answers1

0

Just type $ git log submodule1, and the oldest commit is what you want.

Or you can add --reverse option, and the first commit is what you want.

And notice you can't type it as $ git log submodule1/, which is likely autocompleted by bash.

And from this question, Find commit where file was added.

You can type git log -p --diff-filter=A -- submodule1

Community
  • 1
  • 1
pktangyue
  • 8,326
  • 9
  • 48
  • 71