I’m using several resources to teach myself Git: Ed’s Git for Visual Studio O’Reilly course, the Pro Git book, this particular Git Visualization tool, and the Git for Humans book. (If I’m missing a good intermediate resource, lmk!) As I study a concept in one course, I’ll go back and re-read that section in another book or course to see if there are any surprises that I didn’t catch the first time.
As I started re-reading the section on merging in Git for Humans, it hit me that I had missed one important difference between a git merge and a fast-forward – the merge commit!
I’ll use the Git Visualization tool to demo:
When you do a fast-forward merge, the commits from the feature branch (source branch?) are simply added to the master branch (target branch?), as soon in Tip 92 – how to do a fast forward merge
However, if we’re doing a real merge (e.g. there are conflicts that have to be resolved or you pass in the –no-ff option as we’ll have to do with this visualization tool), you’ll see that a new commit, called a merge commit, is added.
I guess Farris had it right (source)
I saw that movie when I was in elementary school. I promised myself when I got into high school I would take a day off and do all the things in that movie. The float scene was possible because of growing up in New Orleans, but the baseball part would have been challenging. I think the closest I’ve ever come to doing something like Farris Bueller was driving to Nintendo HQ (right by the gym I used to go to in Redmond), jumping out of the car, and screaming, “YES I MADE IT!” in homage to all those times as a little kid I entered to win a trip to Nintendo HQ via all those Nintendo Power magazines.
“However, if we’re doing a real merge (e.g. there are conflicts that have to be resolved or you pass in the –no-ff option as we’ll have to do with this visualization tool), you’ll see that a new commit, called a merge commit, is added.”
I don’t think it’s accurate to say that real merges are done when there are merge conflicts. It sounds like you’re saying that having conflicts triggers a merge commit and that’s not what’s triggering the merge commit. Doing a “real merge” (regardless if there are conflicts or not) results in a merge commit.
It’s because master no longer points to the common ancestor that a “real merge” is done vs a fast-forward.
git checkout -b test
git commit
git commit
git checkout master
git commit
(master no longer points to common ancestor)
git merge test
LikeLike
Hey Jeff, great catch! I got sloppy with my vocabulary wrt “real” merges. I wanted to say something like, “in a more real-world example where there are conflicts” and I got too lazy to type out any of my other thoughts in that phrase (other than the word “real”). I’ll fix this in a bit.
LikeLike