A friend has a fork of my project and sent me a pull-request. Without doing any eyeballing at all, I did this:
$ git fetch XXX
$ git merge XXX/master
Git ran a fast-forward merge and now all those commits are in my code. Then I ran some tests and KABOOM.
After spending a while digging around and seeing just how much needed to be fixed, I decided that it would be better to just send an email with the test errors back to my friend rather than try to fix them myself. I got my own work to do, after all.
So I sent the email, but now I had a git checkout with all those commits.
And since this was a fast-forward merge, git didn’t create a commit for the merge.
Incidentally, today I learned that you can force git to make an explicit commit for fast-forward merges like this:
$ git merge --no-ff XXX/master
I went to #git on irc.freenode.org, where I always go, and I explained the situation, and then was told to do these commands:
$ git reflog show master
$ git reset --keep master@{1}
And it worked! All the foreign commits are now gone.
But what just happened?
I’m not absolutely certain, but it seems like the git reflog show master command shows the changes applied to HEAD over time. This is what the top lines showed for me:
cce8252 master@{0}: merge XXX/master: Fast-forward
08c8f50 master@{1}: commit: Cleaning up the my-account pages
5526212 master@{2}: commit: Deleted a handler that was never getting used
This is different than git log. This is talking about the state of my local master branch over time.
Then, the next command git reset –keep master@{1} is telling git to reset the checkout to look like what master looked like one state in the past.
Like I said, I’m still not sure I understand this, but I plan to study it more.