How to Remove GIT Merge Conflicts using Kdiff3 Tool
Many of them face conflicts issue while committing the code.
Follow the below steps to remove the conflicts very easily.
First, you need to install any merge tool in your system to resolve the conflicts.
GIT supports various visual merge tools to resolve the conflicts. Below are the few open source visual merge tools.
-> The git mergetool command allows for the integration of the above tools into the merge process.
-> It has already includes support for a number open source and freely available merge tools like, kdiff3, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff, ecmerge, and opendiff.
Now we will see how to remove conflicts using Kdiff3 merge tool
Download and install Kdiff3 tool from below URL
After downloading add following code in your gitconfig file (path: C:Program FilesGitetc):
path = C:/Program Files/KDiff3/kdiff3.exe trustExitCode = false [difftool] prompt = false [diff]
tool = kdiff3
path = C:/Program Files/KDiff3/kdiff3.exe
trustExitCode = false
keepBackup = false
tool = kdiff3
Once the configuration is done, now you can use this tool to remove any merge conflicts.
Use the following commands after getting the merge conflicts.
-> git mergetool -t [toolname]
Ex: git mergetool -t kdiff3
after that it will ask you to hit return, then press enter, it will open a kdiff tool with code differentiate which causes the conflicts, in the bottom code window select which lines of code you need to commit, after selecting the lines of code, click on save and close the window.
After resolving merge conflicts use below commands to commit the code.
git commit -m ‘’
git push (push the code to remote repository)
Now your code is free from conflicts.