Git mergetool

CBID2's avatar
Published Dec 27, 2023
Contribute to Docs

In Git, a merge conflict is a situation that commonly occurs when merging a branch into a codebase. The mergetool command is often used to resolve this these conflicts.

  • Use our beginner friendly Git course to integrate Git and GitHub and manage versions of your projects using Git branches.
    • With Certificate
    • Beginner Friendly.
      4 hours
  • Learn about the command line, starting with navigating and manipulating the file system, and ending with redirection and configuring the environment.
    • With Certificate
    • Beginner Friendly.
      4 hours

Syntax

git mergetool

Example

Below is an example on how to use git mergetool. The developer runs the command and the merge conflict appears:

git mergetool
# Conflicting section:
<<<<<<< HEAD
## Creating a Tutorial
We highly recommend using Markdown to create your tutorial for our audio editor.
=======
If you need help, check out our templates.
>>>>>>> UPDATING-THE-DOCS
  • <<<<<<< HEAD: where the developer’s changes appear.
  • ====: Divides the developer’s changes from the changes in the other branch, followed by >>>>>>> UPDATING-THE-STYLE-GUIDE

To complete this command, the developer removes the conflict markers <<<<<<<, =======, >>>>>>>, and pushes the changes to the updating-the-style-guide branch with the following commit message:

git commit -m "docs: update information about tutorials"

Other tools

Here are a list of other tools that are used to solve merge conflicts:

  • Kaleidoscope: Developers often use this to resolve merge conflicts due to its use of different highlighted colors and powerful features ranging from a Convert to Merge command, text filters that remove unimportant data, and a debugger.
  • Visual Studio Code: This Integrated Development Environment (IDE) has a built-in 3-way merge editor, which displays the incoming changes to the file and provides a button that enables the changes to be accepted into the file. This allows developers to edit files and resolve conflicts easily.
  • Sublime Merge: Tool comes in a paid and free version. It is deemed to have a great user interface and is intuitively easy to use.

All contributors

Contribute to Docs

Learn Git on Codecademy

  • Use our beginner friendly Git course to integrate Git and GitHub and manage versions of your projects using Git branches.
    • With Certificate
    • Beginner Friendly.
      4 hours
  • Learn about the command line, starting with navigating and manipulating the file system, and ending with redirection and configuring the environment.
    • With Certificate
    • Beginner Friendly.
      4 hours