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.

  • What does this disconnected arrow mean on gitk?
  • Problem with git push
  • remote: Invalid username or password
  • best practice: how to add an external framework to xcode project which is under version control?
  • Git - Accidentally pushed to upstream instead of my branch
  • Safe to delete a branch on Github if it's commits are in another branch?
  • More details:

    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.

  • What is a simple way to Git Push to another machine?
  • ci/cd independent microservices in monorepo with git bash
  • Why does git diff-tree show always show rename as add and delete
  • Force merge files while rebasing with master: GIT
  • Salt-stack error with state git.config
  • Git revert does not work as expected
  • 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!

    Git Baby is a git and github fan, let's start git clone.