1

I am getting the below error when I try to use merge tool in git.

git config option merge.tool set to unknown tool: code
Resetting to default...

This message is displayed because 'merge.tool' is not configured.
See 'git mergetool --tool-help' or 'git help config' for more details.
'git mergetool' will now attempt to use one of the following tools:
opendiff kdiff3 tkdiff xxdiff meld tortoisemerge gvimdiff diffuse diffmerge ecmerge p4merge araxis bc codecompare smerge emerge vimdiff nvimdiff

I want to use vscode as difftool and merge tool.

Here is my config file

[merge]
    tool = vscode
[mergetool "vscode"]
    cmd = code --wait $MERGED
[diff]
    tool = vscode
[difftool "vscode"]
    cmd = code --wait --diff $LOCAL $REMOTE

How can I configure vscode as my difftool and mergetool?

DingRealT
  • 57
  • 6
  • Does running `code --help` from the command line work? Also, are you using Git Bash on Windows, cmd.exe, PowerShell or a different OS entirely? – ElderFuthark Jul 23 '22 at 23:00
  • Git bash on windows, “code” on command line opens vscode @ElderFuthark – DingRealT Jul 24 '22 at 02:25
  • I tested your config on Git bash (2.21.0.windows.1) and it worked flawlessly. Can you please edit your question to include the output of `code --help` and `git mergetool --tool-help`? – ElderFuthark Jul 24 '22 at 02:52

1 Answers1

0

Git bash on windows, “code” on command line opens vscod

That means code is in your %PATH%/$PATH.

If "'merge.tool' is not configured.", that means you are running the Git session with a different account than the one where code, on command-line, work.

In that problematic session, try:

git config -l --show-origin --show-scope|grep merge

Check if merge.tool is indeed set.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250