Search code examples
wordpressgitgit-submodulesgit-checkoutgit-reset

How do I git out of this mess with a git submodule?


I've got a git repo with Wordpress as a submodule. I was trying to update Wordpress and really screwed things up. I just want to get all of the code from the 3.7.1 tag in the remote repository, but this doesn't work;

git fetch --tags
git checkout 3.7.1

Leaves a bunch of either "untracked files" or "uncommitted changes". I don't know what I'm doing wrong. I've tried so many things to get this submodule onto the 3.7.1 tag and nothing seems to work. If anything, I feel like I'm just making the problem worse. It shouldn't be that hard to just reset the code from the tag I want and discard everything else. Any help?


Solution

  • Here's the git nuclear option:

    git clean -dfx             # delete everything in the worktree that isn't tracked
    git reset --hard           # wipe all modifications to tracked files
    git checkout 3.7.1
    

    which looks appropriate here.