Git merge tool windows

Содержание
  1. Git на Windows: как настроить mergetool?
  2. 18 ответов
  3. Git mergetool with Meld on Windows
  4. 9 Answers 9
  5. 1. Windows:
  6. 2. Linux:
  7. Git on Windows: How do you set up a mergetool?
  8. 19 Answers 19
  9. shawndumas / .gitconfig
  10. This comment has been minimized.
  11. glueckandi commented Oct 9, 2014
  12. This comment has been minimized.
  13. haroldGomez commented Dec 9, 2014
  14. This comment has been minimized.
  15. JobaDiniz commented Mar 31, 2015
  16. This comment has been minimized.
  17. jcspader commented Jul 15, 2015
  18. This comment has been minimized.
  19. bhagyesh-bhatewara commented Oct 8, 2015
  20. This comment has been minimized.
  21. martinblore commented Mar 23, 2016
  22. This comment has been minimized.
  23. ZenSoftware commented Apr 21, 2016
  24. This comment has been minimized.
  25. DaveCsimplyhealth commented Apr 22, 2016
  26. This comment has been minimized.
  27. riguelbf commented May 9, 2016
  28. This comment has been minimized.
  29. FabienDehopre commented Jul 6, 2016
  30. This comment has been minimized.
  31. gahrae commented Jul 12, 2016
  32. This comment has been minimized.
  33. clezioalves commented Nov 19, 2016
  34. This comment has been minimized.
  35. tssutha commented Dec 30, 2016
  36. This comment has been minimized.
  37. KarthikeyanMindtree commented Mar 9, 2017
  38. This comment has been minimized.
  39. zoldello commented Mar 23, 2017
  40. This comment has been minimized.
  41. tomytree22 commented Mar 24, 2017
  42. This comment has been minimized.
  43. ghost commented Mar 31, 2017
  44. This comment has been minimized.
  45. StephenChamberlain commented Apr 4, 2017
  46. This comment has been minimized.
  47. MagicUnderHood commented May 27, 2017
  48. This comment has been minimized.
  49. edcolcode commented Jun 3, 2017
  50. This comment has been minimized.
  51. zalizko commented Aug 3, 2017
  52. This comment has been minimized.
  53. Pagliacii commented Aug 8, 2017
  54. This comment has been minimized.
  55. bardware commented Oct 15, 2017
  56. This comment has been minimized.
  57. maiconheck commented Nov 19, 2017
  58. This comment has been minimized.
  59. robertocg72 commented Dec 6, 2017
  60. This comment has been minimized.
  61. picasso250 commented Dec 12, 2017 •
  62. This comment has been minimized.
  63. hiteshkanchan commented Feb 1, 2018
  64. This comment has been minimized.
  65. nonsocode commented Mar 1, 2018
  66. This comment has been minimized.
  67. Tbd19 commented Mar 15, 2018
  68. This comment has been minimized.
  69. angusmillar commented Mar 20, 2018
  70. This comment has been minimized.
  71. antru commented May 8, 2018
  72. This comment has been minimized.
  73. Carcinie commented May 15, 2018
  74. This comment has been minimized.
  75. Carcinie commented May 15, 2018 •
  76. This comment has been minimized.
  77. tiago-aguiar-moreira commented Jun 29, 2018
  78. This comment has been minimized.
  79. cored0wn commented Jul 9, 2018
  80. This comment has been minimized.
  81. aequi42 commented Jul 10, 2018
  82. This comment has been minimized.
  83. mrsaleh commented Jul 28, 2018
  84. This comment has been minimized.
  85. RecoX commented Feb 5, 2019
  86. This comment has been minimized.
  87. k9t9 commented Mar 25, 2019 •
  88. This comment has been minimized.
  89. kpuru2 commented Mar 26, 2019
  90. This comment has been minimized.
  91. jernkuan commented Jun 25, 2019
  92. This comment has been minimized.
  93. mrstecklo commented Sep 4, 2019
  94. This comment has been minimized.
  95. sugardaddy commented Oct 9, 2019

Git на Windows: как настроить mergetool?

Я пробовал msysGit и Git на Cygwin. Оба отлично работают сами по себе, и оба запускают gitk и git -gui отлично.

Теперь как я могу настроить mergetool? (Vimdiff работает на Cygwin, но я бы хотел, чтобы кое-что было немного более удобным для некоторых наших любящих Windows сотрудников.)

18 ответов

Для ответа на вопрос Чарльза Бейли, здесь моя установка git, использующая p4merge (бесплатный инструмент для слияния с тремя платформами 3way); проверено на msys git (Windows):

или, из оболочки windows cmd.exe, вторая строка:

Изменения (относительно Чарльза Бейли):

  • добавлен в глобальную конфигурацию git, т.е. действителен для всех проектов git не только текущей
  • значение конфигурации настраиваемого инструмента находится в «mergetool. [tool].cmd», а не «merge. [tool].cmd» (глупо меня, потратил час на устранение неполадок, почему git продолжал жаловаться на несуществующий инструмент)
  • добавлены двойные кавычки для всех имен файлов, чтобы файлы с пробелами все еще можно было найти с помощью инструмента слияния (я тестировал это в msys git из Powershell)
  • обратите внимание, что по умолчанию Perforce добавит свой установочный каталог в PATH, поэтому не нужно указывать полный путь к p4merge в команде
Читайте также:  Выключился компьютер во время обновления windows 10 не загружается

РЕДАКТИРОВАТЬ (февраль 2014)

Как указано @Gregory Pakosz, последний msys git теперь «изначально» поддерживает p4merge (проверен на 1.8.5.2.msysgit.0).

Вы можете отобразить список поддерживаемых инструментов, выполнив:

Вы должны увидеть p4merge в любом доступном или действительном списке. Если нет, обновите свой git.

Если p4merge был указан как доступный, он находится в вашем PATH, и вам нужно только установить merge.tool:

Если он был указан как действительный, вы должны определить mergetool.p4merge.path в дополнение к merge.tool:

  • Вышеприведенный пример — путь, когда p4merge был установлен для текущего пользователя, а не для всей системы (не требует прав администратора или повышения UAC)
  • Хотя

должен расширяться в текущий домашний каталог пользователя (так теоретически путь должен быть

Git mergetool with Meld on Windows

In Linux, my favorite merge tool is Meld, and I’ve had no problems using or configuring it to work with Git. However, in Windows it has been a different story.

First, I installed Meld from a bundle I found here: https://code.google.com/p/meld-installer/

Then, I configured my .gitconfig like so to support Meld as the default mergetool

So, when I have a conflict, I do git difftool and Meld does in fact open. However, the paths to the files that Git writes to pass to the diff tool is incorrect. For example, even though Git generates the BASE, LOCAL, and REMOTE files in the repository directory (the location I called git mergetool from), Meld tries to open each of those files in the directory of the executable.

Instead of opening C:\repo\roses.txt.LOCAL.2760.txt, Meld tries to open C:\Program Files (x86)\Meld\meld\roses.txt.LOCAL.2760.txt.

Has anyone ran into this before or know how to configure Git / Meld to work correctly in Windows?

9 Answers 9

Why do you not use git bash for Windows?

After install meld simply:

Schuess, be careful for space character in directories!

I had the exact same problem and found I had to brute force my way to get it to work. Here is what I put in my .gitconfig file. (Note my meld executable is in a different location)

How to use meld as your git difftool in place of git diff (see also the screenshots of meld below):

1. Windows:

Download and install Git for Windows, which includes a «Git Bash» Linux-like terminal accessible via the right-click menu in any folder in Windows Explorer, once you’ve installed Git for Windows.

Download and install meld from here: https://meldmerge.org/.

Then, to make meld your git difftool , you can use these two commands, inside the Git for Windows bash terminal, (as Arugin says), using the proper path to Meld.exe:

OR you can just edit your C:\Users\YOUR_USER_NAME\.gitconfig file directly and add the following to the end of it:

Now call git difftool in your Git for Windows bash terminal and Meld will open up as your default difftool viewer! If you don’t already know: you can open said terminal in Windows by right-clicking in a folder in Windows Explorer and going to —> «Git Bash» or whatever it’s called.

2. Linux:

I might as well put the Linux instructions here too for my own reference in one place if nothing else:

For Linux it’s even easier:

Then add to the bottom of the .gitconfig file:

That’s it! git difftool now works on Linux Ubuntu!

Git on Windows: How do you set up a mergetool?

I’ve tried msysGit and Git on Cygwin. Both work just fine in and of themselves and both run gitk and git-gui perfectly.

Now how the heck do I configure a mergetool? (Vimdiff works on Cygwin, but preferably I would like something a little more user-friendly for some of our Windows-loving coworkers.)

19 Answers 19

To follow-up on Charles Bailey’s answer, here’s my git setup that’s using p4merge (free cross-platform 3way merge tool); tested on msys Git (Windows) install:

or, from a windows cmd.exe shell, the second line becomes :

The changes (relative to Charles Bailey):

  • added to global git config, i.e. valid for all git projects not just the current one
  • the custom tool config value resides in «mergetool.[tool].cmd», not «merge.[tool].cmd» (silly me, spent an hour troubleshooting why git kept complaining about non-existing tool)
  • added double quotes for all file names so that files with spaces can still be found by the merge tool (I tested this in msys Git from Powershell)
  • note that by default Perforce will add its installation dir to PATH, thus no need to specify full path to p4merge in the command

EDIT (Feb 2014)

As pointed out by @Gregory Pakosz, latest msys git now «natively» supports p4merge (tested on 1.8.5.2.msysgit.0).

You can display list of supported tools by running:

You should see p4merge in either available or valid list. If not, please update your git.

If p4merge was listed as available, it is in your PATH and you only have to set merge.tool:

If it was listed as valid, you have to define mergetool.p4merge.path in addition to merge.tool:

  • The above is an example path when p4merge was installed for the current user, not system-wide (does not need admin rights or UAC elevation)
  • Although

should expand to current user’s home directory (so in theory the path should be

shawndumas / .gitconfig

[ mergetool ]
prompt = false
keepBackup = false
keepTemporaries = false
[ merge ]
tool = winmerge
[ mergetool » winmerge «]
name = WinMerge
trustExitCode = true
cmd = » /c/Program \\ Files \\ \\ (x86 \\ )/WinMerge/WinMergeU.exe » -u -e -dl \» Local \» -dr \» Remote \» $LOCAL $REMOTE $MERGED
[ diff ]
tool = winmerge
[ difftool » winmerge «]
name = WinMerge
trustExitCode = true
cmd = » /c/Program \\ Files \\ \\ (x86 \\ )/WinMerge/WinMergeU.exe » -u -e $LOCAL $REMOTE

This comment has been minimized.

Copy link Quote reply

glueckandi commented Oct 9, 2014

This comment has been minimized.

Copy link Quote reply

haroldGomez commented Dec 9, 2014

This comment has been minimized.

Copy link Quote reply

JobaDiniz commented Mar 31, 2015

This comment has been minimized.

Copy link Quote reply

jcspader commented Jul 15, 2015

I using with Winmerge 2.14. It’s working!
Tks

This comment has been minimized.

Copy link Quote reply

bhagyesh-bhatewara commented Oct 8, 2015

Life saver. Works like charm. Thanks.

This comment has been minimized.

Copy link Quote reply

martinblore commented Mar 23, 2016

This comment has been minimized.

Copy link Quote reply

ZenSoftware commented Apr 21, 2016

Thank you very much

This comment has been minimized.

Copy link Quote reply

DaveCsimplyhealth commented Apr 22, 2016

Have edited config and am using Winmerge 2.14 but can’t get it working.

This comment has been minimized.

Copy link Quote reply

riguelbf commented May 9, 2016

This comment has been minimized.

Copy link Quote reply

FabienDehopre commented Jul 6, 2016

This comment has been minimized.

Copy link Quote reply

gahrae commented Jul 12, 2016

When using Cgywin, I needed to modify the command as follows.
cmd = «/cygdrive/c/Program\\ Files\\ \\(x86\\)/WinMerge/WinMergeU.exe» -u -e «$(cygpath -wla $LOCAL)» «$(cygpath -wla $REMOTE)»

This comment has been minimized.

Copy link Quote reply

clezioalves commented Nov 19, 2016

This comment has been minimized.

Copy link Quote reply

tssutha commented Dec 30, 2016

This comment has been minimized.

Copy link Quote reply

KarthikeyanMindtree commented Mar 9, 2017

Worked for me. Thanks !

This comment has been minimized.

Copy link Quote reply

zoldello commented Mar 23, 2017

This is the result of mixing «awesome» and «sause».

This comment has been minimized.

Copy link Quote reply

tomytree22 commented Mar 24, 2017

Thanks 🙂 excelent solution

This comment has been minimized.

Copy link Quote reply

ghost commented Mar 31, 2017

Works for me, too. Thank you very much!

This comment has been minimized.

Copy link Quote reply

StephenChamberlain commented Apr 4, 2017

Great solution, thanks very much!

This comment has been minimized.

Copy link Quote reply

MagicUnderHood commented May 27, 2017

This comment has been minimized.

Copy link Quote reply

edcolcode commented Jun 3, 2017

This comment has been minimized.

Copy link Quote reply

zalizko commented Aug 3, 2017

This comment has been minimized.

Copy link Quote reply

Pagliacii commented Aug 8, 2017

Thanks! It worked now!

This comment has been minimized.

Copy link Quote reply

bardware commented Oct 15, 2017

I see a multitude of posts on stackoverflow describing how to use WinMerge as difftool. When a file is created or deleted WinMerge tries to access \\.\nul .
Does your solution address/handle that issue?

This comment has been minimized.

Copy link Quote reply

maiconheck commented Nov 19, 2017

Works for me, too. Thank you very much!

This comment has been minimized.

Copy link Quote reply

robertocg72 commented Dec 6, 2017

Very useful, thank you

This comment has been minimized.

Copy link Quote reply

picasso250 commented Dec 12, 2017 •

NOT git diff

this takes me quite a while

This comment has been minimized.

Copy link Quote reply

hiteshkanchan commented Feb 1, 2018

I made this change in the .gitconfig. Now how do I specify the files for comparison once in Git Bash

This comment has been minimized.

Copy link Quote reply

nonsocode commented Mar 1, 2018

This comment has been minimized.

Copy link Quote reply

Tbd19 commented Mar 15, 2018

Has anyone had problems with this configuration recently on Windows 10 Visual Studio 2017? I am getting this on the output; «Failed to start the configured compare tool. Using the default compare tool instead.»

This comment has been minimized.

Copy link Quote reply

angusmillar commented Mar 20, 2018

This comment has been minimized.

Copy link Quote reply

antru commented May 8, 2018

This comment has been minimized.

Copy link Quote reply

Carcinie commented May 15, 2018

i’m getting the nul path error too

This comment has been minimized.

Copy link Quote reply

Carcinie commented May 15, 2018 •

Tbd19 I had the same problem. This is what i did.
git difftool —tool-help

It should tell you what the available diff tools are.
I did:
git config diff.tool winmerge

This comment has been minimized.

Copy link Quote reply

tiago-aguiar-moreira commented Jun 29, 2018

Very helpfull. Thanks!

This comment has been minimized.

Copy link Quote reply

cored0wn commented Jul 9, 2018

This comment has been minimized.

Copy link Quote reply

aequi42 commented Jul 10, 2018

Thank you a lot!

This comment has been minimized.

Copy link Quote reply

mrsaleh commented Jul 28, 2018

Saved me a lot of time, thanks.

This comment has been minimized.

Copy link Quote reply

RecoX commented Feb 5, 2019

This comment has been minimized.

Copy link Quote reply

k9t9 commented Mar 25, 2019 •

WinMerge was supposed to be a two-way diff ( pending WinMerge3 ) and not a three-way diff as git require. is that updated to 2.16 ( 3 way ) ?

This comment has been minimized.

Copy link Quote reply

kpuru2 commented Mar 26, 2019

This comment has been minimized.

Copy link Quote reply

jernkuan commented Jun 25, 2019

This worked for me to test for empty file and fix the \nul\ problem

cmd = [[ $LOCAL != «/dev/null» ]] && «c:/Program\\ Files/WinMerge/WinMergeU.exe» -u -e $LOCAL $REMOTE

This comment has been minimized.

Copy link Quote reply

mrstecklo commented Sep 4, 2019

Thanks to the author, but I suggest this set of options for mergetool/cmd:
-u -e -fm -wl -dl «Local» -wr -dr «Remote» $LOCAL $MERGED $REMOTE
This way MERGED file is in the middle pane, so you can apply changes directly from LOCAL or REMOTE. Additionally, LOCAL and REMOTE are marked «read only»

This comment has been minimized.

Copy link Quote reply

sugardaddy commented Oct 9, 2019

I tried the diff settings above, but they didn’t work for me. It was the path to winmerge that was not right syntactically. After trying a dozen combinations or so, I finally landed on one that worked.

I’m sure there is a version of the Windows long file name form that works, but I have stopped searching now. PROGRA

1 is the short DOS 8.3 folder name for the «Program Files (x86)» folder where my winmerge is located.

I also tried just using tool=winmerge since that is supposed to be built-in, but it didn’t work.

Tip: running this command would sometimes help me know if my path was not formatted correctly.
git difftool —tool-help

Windows 8
git version 2.21.0.windows.1

Читайте также:  Как размечать диски для windows 10 при установке
Оцените статью