GET 50% OFF GitKraken Pro! Ends Soon

Git Diff

What does ‘diff’ mean in Git? A diff takes two data sets and shows you what has changed between them. Data sets can be files, commits, branches, etc. 

Let’s walk you through the concept of a diff and the benefits of using a robust diff tool, like that offered in the GitKraken Git GUI

If you’re looking for the best Diff tool on the market, look no further than the in-app Diff view offered in GitKraken.

Git Diff Between Commits 

Let’s look at an example using two commits; let’s say we want to see what has changed between Commit 1 and Commit 3. 

A visual diagram showing how the git diff command compares changes between two commits:
	•	Commit 1 includes:
	•	Added: file_01
	•	Modified: file_02, file_03, file_04
	•	Commit 3 includes:
	•	Modified: file_01, file_02
	•	Deleted: file_03
	•	Added: file_05
	•	The resulting Diff between C1 + C3 shows:
	•	Modified: file_01, file_02
	•	Deleted: file_03
	•	Added: file_05

The diagram demonstrates how Git calculates differences in file changes across commits.

The diff will compare the differences between the two commits, showing what files were added, deleted, or modified. 

In this example, Commit 1 is the baseline. You may also notice how the diff looks identical to the changes from Commit 3, and that’s no mistake! The literal difference between Commit 1 and Commit 3 are the changes introduced by Commit 3. 

A visual representation of how Git calculates the difference between two commits on the same file:
	•	Commit 1 shows file_02 with a line removed on line 2 (red) and a new line added on line 3 (green).
	•	Commit 3 further modifies file_02 by adding a new line on line 7.
	•	The Diff between C1 + C3 shows file_02 with only the net change from both commits: a new line added on line 7, reflecting the combined result after the previous changes.

This highlights how git diff outputs the cumulative difference between commits.

Git Diff Between Files

But what about the diff of each file? When examining the diff of each file, added lines of text are commonly highlighted in green or denoted with a + sign. Similarly, deleted lines of text are commonly highlighted in red or donated with a sign. 

The file diff will likely be your most useful tool for understanding what changed, and how it changed.

Why would you want to view a Git diff? 

Diffs provide useful information about your repository in a legible format, making it easier to perform the following actions: 

  • Review changes while staging. 
  • Decide whether to rebase or merge. 
  • Copy and paste code from a file. 

Giving you even more confidence in your code game. 💥

The Diff tool in GitKraken will help you make more informed decisions, allowing you to perform more advanced Git actions, like rebase, with less risk.

The Git Diff Tool in GitKraken 

Let’s see how this all works in the GitKraken Git GUI

If you click a commit in the graph, GitKraken will list all of the files changed on the right commit panel. 

Animated walkthrough of a GitKraken commit review workflow. It begins with selecting a commit authored by Jonathan Silva in the commit history panel. The right panel displays 11 modified files, including docs/account/buy.md, faq.md, and several documentation images. The view then transitions into the diff view for buy.md. In the second frame, yellow arrows highlight lines added, such as updated registration links and new billing instructions. In the third frame, as the user scrolls, yellow arrows now indicate lines removed, including outdated account creation guidance and legacy notes, providing a clear view of the file’s before-and-after state.

Click on any file to open that file’s diff. Lines that were added to that file will show in green, and lines that were deleted will show in red. If code has been added and deleted from the same line, GitKraken will show both together. 

Hunk, Inline, and Split Diff Views 

By default, GitKraken’s Git diff tool will display in Hunk View, which displays the file changes in blocks of code, helping reduce the noise of seeing the entire file. 

Side-by-side comparison of GitKraken’s diff views: The first frame shows an inline diff view highlighting added (green) and removed (red) lines within a single scrollable pane. The second frame shows split view, displaying original file contents on the left and updated contents on the right, clearly marking the differences between them. Both views highlight code changes made to a Markdown file, helping developers visualize edits.

However, you can toggle between Inline View, which shows the changes within the context of the entire file, or Split View, which will show you how the file appeared before and after the changes. 

View the Git Diff when Staging Files 

These options are also available when staging files. For example, try reviewing the file diffs and switching between Hunk, Inline, or Split views to make the most informed commits. 

GitKraken’s Diff tool gives you the ability to toggle between different views, so you can view your code exactly how you want to make the best decisions.

Git Diff Between Branches 

There are a few more things you can do with the Git diff in the GitKraken Git GUI

From the central graph in GitKraken, hold down the Cmd/Ctrl key to select the head commit of two branches. From here, you will have the option to view the diff between these two branches.

But what happens when you change the order of the branch selection? When you give that a try, you may see deleted files show as “added” or vice versa. That’s because direction matters when viewing a Git diff.  So keep that in mind as you click the order of branch or commit diffs. 

Customize Text Editor Preferences

GitKraken also allows the ability to easily customize preferences of the text editor available in the Git diff tool. Simply navigate to PreferencesEditor Preferences, where you can customize your Git diff tool preferences for syntax highlighting, line count, and word wrap. 

Additional Resources

Table of Contents

Make Git Easier, Safer &
More Powerful

with GitKraken

Visual Studio Code is required to install GitLens.

Don’t have Visual Studio Code? Get it now.

Team Collaboration Services

Secure cloud-backed services that span across all products in the DevEx platform to keep your workflows connected across projects, repos, and team members
Launchpad – All your PRs, issues, & tasks in one spot to kick off a focused, unblocked day. Code Suggest – Real code suggestions anywhere in your project, as simple as in Google Docs. Cloud Patches – Speed up PR reviews by enabling early collaboration on work-in-progress. Workspaces – Group & sync repos to simplify multi-repo actions, & get new devs coding faster. DORA Insights – Data-driven code insights to track & improve development velocity. Security & Admin – Easily set up SSO, manage access, & streamline IdP integrations.
winget install gitkraken.cli