0

In our repo there is a submodule (listed in .gitmodule file). Instead of adding it with git submodule update command, one of my teammates cloned the submodule to a different directory and added a symlink to that folder in our repo. This was being used just in their local.

But someday, it was accidentally commited (maybe because of git add --all) and pushed to remote. When I pulled that branch to my local, the symlink got downloaded and ever since that folder is not considered as a submodule but as a file part of this repo. I did a git rm on that file and did a commit.

But issue comes back whenever we checkout this branch. The submodule folder will staged to be deleted. Unfortunately, there have been lot of commits over this commit. So undoing the commit is tedious. What's the best course of action now?

aniztar
  • 2,443
  • 4
  • 18
  • 24
  • There is no best way. Possible solutions: (1) rewrite history such that the symbolic link never enters the picture. (2) Fix it now and live with the breakage when a broken commit or branch must be checked out. – j6t Jun 06 '23 at 06:23
  • Have you checked https://stackoverflow.com/questions/43762338/how-to-remove-file-from-git-history ? – Ôrel Jun 06 '23 at 08:09

0 Answers0