Compare Code Changes With Meld

Meld Visual Diff And Merge Tool Showing Comparison

The Visual Diff And Merge Tool For Developers

Meld compares files, folders and version controlled projects.

Meld can perform three-way comparison if desired. Merge branches, resolve conflicts visually side-by-side for popular version control systems such as Git. Meld is free, open source and cross-platform (Mac, Windows and Linux) and integrates seamlessly with popular IDEs.

Identical files will not produce an output. It is not wise for Binary files to be opened directly.

The focus of this tutorial will be on the differences between 2 text files, 2 binary files and 3 folders.

  1. Creating 2 files and 3 folders.
  2. Running the Meld command on the 2 files.
  3. Running the Meld tool on the 3 folders.
  4. Explaining the output diff or patch.

Requirements For Using Meld

Glossary:

IDE

Integrated Development Environment is a software application used for software development.

Patch

Set of differences.

Diff

Tool used to compare files or sets of files and highlight their differences.

Merge

Combines changes from different versions or branches of a project into a single, unified version.

Binary File

Computer file that is not a text file.

Tools

Programming Tools
Name Description Example
Bitmap editor For creating and editing bitmap images GNU Image Manipulation Program (GIMP)
Text editor For creating and editing source code Apache Netbeans IDE
SSH Secure Shell Client OpenSSH
Shell Access Access to the command line. Terminal
Meld File comparison utility. Meld
Name Description Example

Create First Text File

# Create New Text File #
cat > test1.txt << 'EOF'
Check out the awesome feature
On Ojambo.com
For making a donation
In the header bar
EOF

Create Second Text File

# Clone New Text File #
cp test1.txt test2.txt

Create Third Text File

# Create New Text File #
cat > test3.txt << 'EOF'
Check out the awesome feature
On OjamboShop.com
For taking a course
In the header bar
EOF

Compare Any Two Files

# Compare Files With Meld #
meld test1.txt test2.txt
meld test1.txt test3.txt
meld test1.jpg test2.jpg
meld test1.jpg test3.jpg

Compare Any Three Files

# Compare Files With Meld #
meld test1.txt test2.txt test3.txt
meld test1.jpg test2.jpg test3.jpg
meld test1.txt test2.txt test1.jpg

Explanation:

  1. The first and second files are the same.
  2. The first and third files are different.
  3. Binary files out only state if they “differ”.

The Meld tool will compare 2 or 3 files and folders. Access the “Format as Patch…” feature from the Comparison menu in Meld.

Meld Visually Compare 2 Binary Images
Meld Visual Comparison Of 2 Binary Images Displaying Problems

Meld Visually Compare 2 Text Files
Meld Visual Comparison Of 2 Text Files Displaying Differences

Meld Visually Compare 3 Text Files And Patch
Meld Visual Comparison Of 3 Text Files Displaying Differences And Save Patch

Meld Visually Compare 2 Git Project Folders
Meld Visual Comparison Of 2 Git Project Folders Displaying Differences

Meld Visually Compare Same File In Git Project Folders
Meld Visual Comparison Of The Same File In 2 Git Project Folders Displaying Differences


Usage

You can start Meld on the command-line, file manager or from the application start menu. For this tutorial, Meld was used on text files and binary files. Meld can be downloaded from Meld.

Open Source

Meld is licensed under the GNU General Public License Version 2.0 or later. The copyleft license comes with strict rules and requirements to ensure the software remains free and open-source. It allows commercial use, modification, distribution, and allows making derivatives proprietary, consult the license for more specific details.

Conclusion:

Meld is a powerful visual diff and merge tool. Developers can use the tool streamline code reviews and resolve conflicts. Meld can compliment source code management version control systems such as Git in merging branches.

The programmer can determine which changes to revert based on the line number output. Use Meld to annotate code, provide clear feedback, and track changes during code reviews.

If you enjoy this article, consider supporting me by purchasing one of my WordPress Ojambo.com Plugins or programming OjamboShop.com Online Courses or publications at Edward Ojambo Programming Books or become a donor here Ojambo.com Donate

References:

Leave a Reply

Your email address will not be published. Required fields are marked *