gitgit-detached-head

Git: abandon bad commit and make HEAD the mainstream


enter image description hereI made some changes to this repository and checked them in and pushed (4326b5, "Waypoint"), before falling back to the previous well behaved commit, 64b7d01 "Merge commit". Then I made some changes from that point and they solved a lot of bugs I had been having. Not going to let that get lost! Now, how to untangle the mess?

Scenario one: yesterday. I had a bunch of changes that I wanted to keep, and I had HEAD at "merge commit". What I really wanted to do was abandon "waypoint" and set master pointing to "merge commit". Reading online it seemed that the advice was to git reset --soft HEAD. However, this accomplished absolutely nothing. What was the right way to do that?

Scenario two: today. Rather than risk my valuable changes, I went ahead and did a commit on the detached head. Now, nearly the same question: how can I get master and origin/master both pointing to bc35e77 "Correctly reports" and abandon "Waypoint" as a detached head or irrelevant branch or something of the sort?


Solution

  • If you have push permissions on the master branch remote repo, then you can do the following: