Git: How to revert a symlink commit which replaced a submodule?
I have a submodule in my main repository called
third-party. Since this module was too big, I had created a symlink to
third-party folder in my workspace.
To my misfortune, I have committed this symlink into my branch as part of big fat merge! Basically, I have replaced a submodule with a symlink.
I have tried to delete the link and submodule update, it didn’t help.
cat .gitmodules outputs the following
[submodule "third-party"] path = third-party url = http://my-git-server/third-party.git
ls -la outputs the following
drwxr-xr-x 3 user admin 136 Jul 26 17:57 some-folder drwxr-xr-x 3 user admin 102 Jul 26 17:57 third-party -> /some/dead/path
I have no idea how to recover from this situation. Any help is greatly appreciated.
One Solution collect form web for “Git: How to revert a symlink commit which replaced a submodule?”
I tried multiple things and finally the following worked. Better ways to solve this are welcome!
#delete the symlink rm third-party #delete the symlink from git git rm third-party #remove the submodule cat /dev/null>.gitmodules #commit the changes git add . git commit -m "Removing third-party as submodule" #add the submodule again git add submodule http://my-git-server/third-party.git third-party #get the latest code from the submodule git submodule update --remote
This fixed my problem. Though the commit hash that third-party is pointing now is different, when I do
git submodule update --remote, I get the latest code!