I created a branch to do some work on, tried to merge another branch into it, and immediately ran into an insurmountable merge conflict. Clearly the thing to do was abandon the branch and start over.
I tried deleting the branch, but that didn't work, because it was the current branch.
I tried checking out another branch (the branch I'd just branched from), but that didn't work:
error: you need to resolve your current index first I had started resolving one of the conflicts, but abandoned it — that is, without committing it. My first thought to resolve the "you need to resolve" error was to do a git add on the file where I'd been resolving conflicts. I did so, then tried the git checkout again. It worked! Hooray!
I was then able to delete the broken branch.
But then I noticed that something was still wrong, because my index was still full of changes deriving from, I presume, the abandoned merge. In other words, git diff --cached generated nonempty output.
So what did I do wrong, and what should I do instead?
Also, I'm sure I'm wrong, but it seems to me that my git checkout still shouldn't have worked, that I still should have gotten something like that "you need to resolve your current index first" error. I would have thought that, after a successful git checkout, git diff --cached would always show nothing.
(The last question, which I'm not asking because I know I should be able to figure it out myself, is how to get a clean index now. Probably git reset, but I've got to double-check that before I try it.)