How to do a non-fast forward merge in Visual Studio – 093

Yesterday’s tip was about how to do a fast forward merge, which shows all the commits still in a linear graph.

linear graph from a fast forward

Today’s tip is how to do a non-fast forward merge, meaning the graph history will show the branch being merged in

graph showing the branch merge for non-fast forward

Note: I had to use Visual Studio 2015 for this demo. There seems to be a bug in Visual Studio 2017 where the checkbox isn’t respecting local repo settings.

Let’s suppose you have a branch called test that you want to merge into master, but you want to retain the merge history in the graph.

Follow all the steps from yesterday’s tip, but today, you’ll uncheck the Commit changes after merging

image

Now you’ll get a message in Visual Studio. note: VS 2017 ignored the unchecked box and did the commit anyways.

merge in progress message

Train yourself to take a deep breath whenever you see a message from Git.

Switch to the Changes page, write a commit message, and hit commit staged.

committing a merge in progress in Changes window

And now your git history shows the merge from the branch.

merge from the branch now in the graph history

Visualizing what we did

We have a commit on the test branch we wish to merge, but retain the history.

git visualization tool showing a test branch

Now we’ll do a merge, but notice we’re using the –no-ff option, which means “no fast-forward” this time.

test being merged into master using no fast foward

Note: looks like the visualization tool requires at least 2 commits to demo the –no-ff option. Otherwise, you’ll get an error.

Does someone want to open a bug in the tool’s repository and call First! in the comments below?  I’m too tired from trying to stay awake to watch Samurai Jack. Why Comedy Central? Why did you think it was an okay April Fool’s Day joke to put some random cartoon on at the 8pm slot??  It’s only 9:47pm and I can’t stay awake to log bugs, much less make it to 11pm for Samurai Jack repeat. Or what if they don’t show Samurai Jack and repeat the cartoon?! See what your April Fool’s joke has done?!  I‘m off to bed.

3 thoughts on “How to do a non-fast forward merge in Visual Studio – 093

  1. “VS 2017 ignored the unchecked box and did the commit anyways.”

    I’ve noticed this, too. I’ve been unable to get VS 2017 to not commit a fast-forward merge. I have to git merge –no-ff from the CLI.

    Like

  2. Frankly. Git integration is ok in visual studio. I use gitextensions to manage git. The lack of line staging is a deal breaker for me. When I have a few mods and I want to only include a few new files and only include those file adds in the project for one example.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s