

You can add the below to your ~/.gitconfig file and when you use git difftool our new merge-wrapper will be used to pick diff tools based on file extension. Say we placed our merge script in the following directory: $HOME/dotfiles/tools/merge-wrapper.js. But since you are using VSCode as your editor. Display line numbers when comparing and merging files. Recognize line-ending conventions for Windows, Mac, and Unix. Choose to include or ignore line endings/white spaces.

You can: Highlight and edit text file differences.
Set p4merge as git mergetool but how to#
Now that we've created our merge wrapper script we need to tell git how to use it. See the differences between file versions and easily resolve conflicts with P4Merge. I'd be happy to take contributions of other diff tools in this gist if you leave a comment with yours.īelow was an attempt at using a bash script to manage what I do above, it'll work for some, but I didn't want to maintain this - prefer the JS version instead. to make it easier to use, setting Gits default merge tool to it. Leave me a comment (either here - or in the gist) of what diff tool you added. The command-line Git client will still find these files, but making them visible will. If you want to change which tool is used per file extensions you can modify the diffLookup hash to map various extensions to whatever tool you setup. Modify which diff tool is used per extension: If you want to extend the script to add support for your own diff tool, just create a new function that returns an object following the pattern of the existing createP4MergeCommand or createOpenDiffCommand. go to the team explorer changes pane to start resolving conflicts. I haven't yet tried to run this on windows, but suspect we can wrap the merge-wrapper.js in a. from vs team explorer, localize the local git repository and open it. js version (above that) since it is easier for me to maintain. sh file (bottom), but changed over to the. Below I have 2 samples of a merge script. To allow us the flexibility we want to determine which diff tool should be used for different file extensions, we need to break out the logic in to an external script. I'm going to put this here so I can find it later. How to setup git to allow different merge/diff tools based on file extension.
