I have main:
* 38f4e95 - (HEAD -> main, origin/main) …
* 2abcc91 - nginx configs blue and green …
From main, I merge a branch and now I have:
* 461eb66 - (HEAD -> main,
|\
| * 38f4e95 - (origin/main) .
| * 2abcc91 - nginx configs b
| * 320c676 - Merge branch
| |\
| * | 46d0cbd - fix filter (3
* | | 7ea521f - EF Migration
I expect HEAD^ after a commit to be “the HEAD from just before I commited anything” i.e. 38f4e95. But it isn't, it's a commit from days ago with a whole bunch of work missing. Why?
Instead HEAD^2 is what I expect to be HEAD^1 (aka HEAD^).
My habit before merging into main is to first merge from main into branch (so issues are found and fixed in the branch). Does this make a difference?
Of course the question springs from wanting to undo the merge. It seems like
git reset HEAD^ --hardshould be just the thing for undo last commit, but instead I have to either be really careful or first note down what the “previous” commit was, or else hope that reset from a remote will neatly solves it.