How to revert a Git Submodule pointer to the commit stored in the containing repository?

前端 未结 7 1302
感动是毒
感动是毒 2021-01-29 22:44

I have a git submodule in my main git repo. As I understand it, the main repo stores a SHA value (somewhere...), pointing to the specific commit of the submodule that it is \"li

7条回答
  •  北恋
    北恋 (楼主)
    2021-01-29 23:23

    Another case I just ran into is if there is an unstaged change in the submodule that you want to discard. git submodule update will not remove that change, nor will git reset --hard on the parent directory. You need to go to the submodule directory and do a git reset --hard. So if I want to fully discard unstaged changes in both my parent and submodule, I do the following:

    In Parent:

    git reset --hard
    
    git submodule update
    

    In Submodule:

    git reset --hard
    

提交回复
热议问题