Yesterday’s tip was about how to do a fast forward merge, which shows all the commits still in a linear graph.
Today’s tip is how to do a non-fast forward merge, meaning the graph history will show the branch being merged in
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
Now you’ll get a message in Visual Studio. note: VS 2017 ignored the unchecked box and did the commit anyways.
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.
And now your git history shows the merge from the branch.
Visualizing what we did
We have a commit on the test branch we wish to merge, but retain the history.
Now we’ll do a merge, but notice we’re using the –no-ff option, which means “no fast-forward” this time.
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.
“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.
LikeLike
This appears to have been fixed in an upcoming release: https://developercommunity.visualstudio.com/comments/39264/view.html
LikeLike
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.
LikeLike