Categories
IT

How to share TortoiseGit settings between multiple machines

The official documentation says:

If you want to export all your client settings to use on another computer you can do so using the Windows registry editor regedt32.exe. Go to the registry key HKCU\Software\TortoiseGit and export it to a reg file. On the other computer, just import that file again (usually, a double click on the reg file will do that).

Remember to save Git’s general settings, which you can find in the Git configuration file .gitconfig and/or the folder .config/git which both are located in your user profile directory.

Unfortunately, in general it may not be so simple:

  • There are some values which should probably never be shared between different TortoiseGit installations, e.g. CurrentVersion.
  • There are some values which you may not want to share between installations, e.g. those beneath the subkey HKEY_CURRENT_USER\SOFTWARE\TortoiseGit\History if you have one installation at home and one at work.
  • Some values will only be created when you change the configuration to be different then the default. E.g., a new installation will not have any values for context menu configuration. If you would use a .reg file on another new installation, that would not be a problem. But if the other installation would already have values for non-default configuration, you would not overwrite the non-default configuration with the default configuration by importing a .reg file.

Thus, you must carefully pick all the values you want to share. If you want to share default values, you must first deviate from the default values so that the values will be saved to the registry and then revert back to the default values, which will then be saved to the registry as well.

I can not offer you a complete solution, but I will now walk you through the settings that I like to share between installations and show you how to set them with PowerShell.

Settings > General > Context Menu

The values are named ContextMenuEntries and ContextMenuEntrieshigh (not ContextMenuEntriesHigh). They seem to be the two halfs of a bit field where each bit represents a context menu item checked or unchecked.

You can make them appear in the registry by selecting all items, saving, restoring to default values and saving again. At the time of writing – using TortoiseGit 2.13.0.1 – the defaults are 1030 and 20, respectively (in decimal notation).

Set-ItemProperty "HKCU:\SOFTWARE\TortoiseGit" "ContextMenuEntries" 1030
Set-ItemProperty "HKCU:\SOFTWARE\TortoiseGit" "ContextMenuEntrieshigh" 20

Settings > General > Context Menu 2

The values are named ContextMenuExtEntriesLow and ContextMenuExtEntriesHigh and work analogous to those in the context menu.

At the time of writing, the defaults are 40000000 and 12000, respectively.

Set-ItemProperty "HKCU:\SOFTWARE\TortoiseGit" "ContextMenuExtEntriesLow" 40000000
Set-ItemProperty "HKCU:\SOFTWARE\TortoiseGit" "ContextMenuExtEntriesHigh" 12000

Settings > Diff Viewer

If you configure a custom diff viewer, the command to call it will be saved in the value named Diff. For using the built-in diff viewer, this value must be absent or prefixed with #.

$DiffMergePath = "C:\Program Files\SourceGear\Common\DiffMerge\sgdm.exe"
$DiffMergeArguments = "/title1=%bname /title2=%yname %base %mine"
$Value = $DiffMergePath + " " + $DiffMergeArguments
Set-ItemProperty "HKCU:\SOFTWARE\TortoiseGit" "Diff" $Value

Settings > Diff Viewer > Merge Tool

This works analogous to the diff viewer, using the value named Merge.

$DiffMergePath = "C:\Program Files\SourceGear\Common\DiffMerge\sgdm.exe"
$DiffMergeArguments = 
    "/merge /caption=%mname /result=%merged /title1=%yname /title2=%bname /title3=%tname %mine %base %theirs"
$Value = $DiffMergePath + " " + $DiffMergeArguments
Set-ItemProperty "HKCU:\SOFTWARE\TortoiseGit" "Merge" $Value

Log dialog > Columns

The column configuration is located in the subkey HKEY_CURRENT_USER\SOFTWARE\TortoiseGit\StatusColumns. I am only interested in logloglist and logloglist_Order.

Set-ItemProperty "HKCU:\SOFTWARE\TortoiseGit\StatusColumns" "logloglist" 1f1
Set-ItemProperty "HKCU:\SOFTWARE\TortoiseGit\StatusColumns" "logloglist_Order" "000102030405060809070A0B0C0D"

At GitHub, you can find my personal configuration script
Set-TortoiseGitSettings.ps1.

Click to rate this post!

[Total: 0 Average: 0]

Leave a Reply

Your email address will not be published. Required fields are marked *