Home > Software design >  Git submodule update gets stuck at old commit
Git submodule update gets stuck at old commit

Time:11-23

Ok this one is driving me crazy. I tried committing/pushing/updating a parent repository with a file from its submodule open in another program (a XLS spreadsheet). The operation "succeeded" with only a Couldn't unlink old somefile.xls warning.

Now I'm trying to git submodule update and it keeps pointing to an old commit several steps back. Git log on the submodule main branch shows that HEAD is the latest commit both locally and remotely, but whenever I cd back and forth to the parent repository it ends detached on this old commit.

I tried manually updating the reference in .git/modules/mysubmodule/HEAD (which is pointing to this old commit) but apparently that's not how things work. How can I get out of this frustrating loop? I suppose making some insignificant changes to the submodule and making a new commit could fix it (I tried an empty commit without luck though), but I want to better understand what happened so I can avoid this situtation in the future.

Here's my submodule git log:

commit 713a39e531463eb9a9a608344ca39acbe520c7c4 (HEAD -> main, origin/main, origin/HEAD)

Here's what git submodule update outputs:

Submodule path 'data': checked out '7e4dc2354f5e60a8efb101a5d8a03466a911d86f'

CodePudding user response:

Your mistake here lies in thinking that submodules should work.

  • Related