Search code examples
gitgit-bashsmartgit

How to untangle the mess I made out of my GIT repository?


I'm super new to GIT, and thought I could create a simple test commit/push. In the process I ended up with a mess shown in the attached image.

enter image description here

The question is, what GIT commands do I need to invoke to remove all the stuff above the red arrow and leave origin/master at the point where the red arrow is?

I don't care about any files in my local clone of the repository. When this mess is fixed, I can just re-clone.


Solution

  • Assuming you're on your local version of master, I'd go with:

    git reset --hard 4c5222c0
    

    That brings your local repo to the hash of the commit pointed by the red arrow.

    Then you can force push to master, for example like that:

    git push origin +master