0

A developer here ran the steps we recommend for git usage, and has lost a submodule commit. I understand that this error means that she pushed in the super project but not in the submodule, but she denies this and has a history of her commands that she showed me. Here are the steps that seemed to have caused this. I would like to understand how to tell her to avoid this in the future.

  • She committed in the submodule and in the superproject.
  • she pulled in the latest on her branch. This caused a submodule conflict with no real content conflicting
  • she ran git commit -a in the superproject to resolve it. (It would be helpful to understand this type of conflict too).
  • She ran a merge from another branch and committed in both places.
  • She ran a global push which cds into each submodule, runs push and then runs push in the superproject.

At this point, her work committed in the original commit in the submodule disappeared from git log.

user561638
  • 1,299
  • 3
  • 15
  • 26
  • 1
    At what point does `reference is not a tree` error happens? – CharlesB Jul 14 '11 at 14:56
  • at the end of the steps I outlined above, I made a clone of her commit in the superproject that she made before her pull and merge, then I tried to checkout the commit id in the submodule. This is when I got the not a tree error. However, she noticed that her changes were gone from the submodule immediately after she finished the pull/merge/push. git log output doesn't list the commit made in the submodule at all now. – user561638 Jul 14 '11 at 15:35

1 Answers1

1

I suppose the commit was lost when she solved the submodule conflict. It can be retrieved by following instructions in this question.

Or run

gitk --all $( git fsck --no-reflog | awk '/dangling commit/ {print $3}' )

(This is from this question)

Only do it on the original repo (as git clone will delete dangling commits), and make a backup of it before.

Community
  • 1
  • 1
CharlesB
  • 86,532
  • 28
  • 194
  • 218
  • I would agree with you, but how can we help the developers who are all new to git so that they don't do this kind of thing?? And what causes submodule conflicts like this? – user561638 Jul 14 '11 at 17:08
  • This may be another question, I don't know submodules very well... But being careful on merging wild beast such as submodule must be done very carefully. – CharlesB Jul 15 '11 at 06:45
  • BTW did she recover the commit? – CharlesB Jul 15 '11 at 06:45
  • No, she didn't wait for me to be in work. She re-implemented the changes. – user561638 Jul 15 '11 at 18:37