Select git mergetool based on file type

elsevers

When running git mergetool, I'd like to have git select the merge tool used based on the file extension. How can I do this?

A similar question was asked here: Git: configure patterns for difftool and mergetool and the answer was to write a custom merge driver. However, it seems like this would be executed upon git merge, whereas I would like the merge tool to be chosen upon git mergetool.

It seems like there must be some way to specify this with .gitattributes, but I can't seem to figure out how. Any advice?

VonC

One solution (since my old answer isn't a good fit for mergetool) is to set as a mergetool a wrapper script.

git config --global merge.tool customMergeTool
git config --global mergetool.customMergeTool.cmd 'customMergeTool.sh \"$BASE\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\"'

That wrapper script customMergeTool.sh would:

  • check what $BASE is (in particular, its file extension)
  • call the appropriate merge tool based on that extension
  • return the exit status of that mergetool

Here is for instance the script that the OP elsevers came up with: merge-wrapper.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

`git mergetool`, A `fileName.~fileType` file was produced

From Dev

Recover file deleted using git mergetool

From Dev

'git mergetool' with meld fails creating a '--output $MERGED' file

From Dev

GIT: Manually invoke 3-way-mergetool on a file on 2 branches

From Dev

Is it possible to git color based on file type?

From Dev

Amending a git mergetool job

From Dev

adding winmerge as mergetool in git

From Dev

Git conflict - mergetool not configured

From Dev

Configuring multiple git mergetool and difftool so that appropriate tool will be chosen based on extension

From Dev

git vimdiff mergetool basic commands?

From Dev

Problems using diffmerge mergetool with git

From Dev

Problems using diffmerge mergetool with git

From Dev

Error mergetool code compare in git

From Dev

force git mergetool to amend a previously done merge

From Java

Git mergetool generates unwanted .orig files

From Dev

Git mergetool meld on windows using putty

From Dev

Git launches mergetool without any arguments

From Dev

How to make git mergetool aware of diff markers

From Dev

Why does my Git mergetool configuration not work?

From Dev

Git mergetool meld on windows using putty

From Dev

Git launches mergetool without any arguments

From Dev

Resolve conflicts automatically with git-mergetool

From Dev

File type based indentation in Kate

From Dev

File type based indentation in Kate

From Dev

Detect file type based on content

From Dev

Input type file on select option

From Dev

Select a particular type of file in java

From Dev

Windows file association based on file type and then size

From Dev

JS: Change input type based on select option?

Related Related

HotTag

Archive