How to manually commit your own merge commit – 103

Following from yesterday’s tip, suppose you have a branch that you plan to merge, but before the merge is committed, you want to verify things. Perhaps you want to hit F5 or perform some other testing. In other words, you are telling git, “Do the merge, but allow me to hit the commit button.”

I guess this is an inverse of “sudo make me a sandwich” which would be “hey sudo, about that sandwich, if you take all the stuff out of the refrigerator, I’ll finish making it myself.”

git merge –no-ff –no-commit branch-name

Note: I’m using the –no-ff option because I don’t have an actual merge conflict in my branch, so I need to tell git not to do a fast-forward.

git status showing all conflicts fixed but you are still merging

If you do a `git status` you’ll see that all conflicts fixed, but you’re still merging, just as the scary (master|MERGING) tells you.

Notice how the next line tells you to do a `git commit`and the Changes to be committed looks like a good old staging message.

From here, we just need to do a `git commit` (which would open your `git config core.editor` – mine is set to notepad. baby steps)

Or you could skip the editor (in case the scary Vi appears) and do

git commit -m “my merge message”

git commit -m "merged mybranch4" then a git log

And doing a `git log` shows the initial readme being added, then the commit from the mybranch4, then the merge commit!

Leave a comment