Compare (Diff) branches in Tortoise Git, or how to preview changes before doing a merge

From "https://wikgren.fi/compare-diff-branches-in-tortoise-git-or-how-to-preview-changes-before-doing-a-merge/"



Compare (Diff) branches in Tortoise Git, or how to preview changes before doing a merge


I’ve recently switched over from SVN to Git in my version control. I’m a Windows user who’s used TortoiseSVN, so I was glad when I found out about TortoiseGit, which presents a very similar user interface to good ol’ TortoiseSVN. Still, there was lots to learn, as Git has a fundamentally different logic in storing the repository, both locally and remotely. Committing changes is a two step process unlike SVN’s single step.
Anyway, when doing software development in a project with several developers developing many braches, it’s sometimes nice to be able to take ‘sneak peek’ into the future and see what will happen when the branches are finally merged to one.
So how do you answer the question “what changes would be made if I merged these two branches right now?” Will there be any conflicts, for example? You could of course pull the changes from one branch to the other, but that is not always desirable.  There is a way to compare branches in TortoiseGit, but it’s faily well hidden by default.
Here’s how you can preview the changes before actually making them:
  • Shift-“right click” on your git folder
  • Select TortoiseGit >> Browse Reference
  • Select two branches from the list (hold shift to select more than one)
  • Right click and select “Compare selected refs”
This opens a window that displays the diff between the branches. Note that the diff is displayed as if the bottom branch (“Version 2”) was merged into the top branch (“Version 1”). There’s an arrow button at the top that lets you change the direction of comparison.

Comments

Popular posts from this blog

Add GitHub Repository to DBeaver CE Secured with SSH Protocol

Keyboard Shortcut to "Toggle Line Comments" in DBeaver

DBeaver Shortcuts