DEV Community

Git Diff Guides

Git diff helps track the differences between changes to a file. It is a multi-use command which can be executed in different contexts. Learn more in these guides.

This is a collection of top and trending guides written by the community on subjects related to Git Diff concepts. For all things git, check out the git tag! Please contribute more posts like this to help your fellow developer in need.

Delta: A new git diff tool to rock your productivity

The delta tool (a.k.a. git-delta, a.k.a. delta-diff) is a diff viewer written in Rust 💪. Initially made to have a better Developer Experience using the git diff command, but has evolved enough transcending a simple diff for git.


How to diff Excel VBA code in SourceTree (Git client)

xltrail is a version control platform for Excel files and works similar like GitHub, BitBucket or GitLab with the difference that xltrail understands the content of Excel files.

While xltrail allows you to integrate with all of these Git providers, it also offers a free and open-source Git extension Git XL that allows you to diff and merge your VBA code locally either on the command line or most recently also through SourceTree.

You can download Git XL here. Note that you do not have to open an account to be able to use it. After clicking your way through the installer, you can activate the extension either globally for all repos (git xl install) or for specific repositories only (git xl install --local while being in a specific repo). For details see the instructions here.

If you now head over to your command line and run a Git diff command, it'll happily show you what changed in your VBA code:


Cool json git diff command

git diff is great but kinda sucks when reporting about deep keys updates in JSON files, because it only shows the last key, and not the whole object path to the updated key


Git diff explained

I use git diff almost every working day to verify code changes, review teammate's code, or trace histories and find out what happened. However, I only learnt to read the raw git diff last year, when I tried to extract what function, variable or class are changed here.


Git Diff of Current and Previous Version of a File

Open the file you want to diff with.


How to use terminal to make git diff beautiful

There is the word diff feature in git.

Let's activate it now!


git diff-filter

Git commands such as diff, log, whatchanged all take a flag called

--diff-filter. This can filter for only certain types of diffs, such

as added (A), modified (M), or deleted (D).


⚙️ ❮ Zsh Diff-so-Fancy ❯

This will install diff-so-fancy on every account where you use Zshell, and automatically equip git with subcommand dsf. No need to use system package manager and to configure git. Of course, if you have the following standard line in your .gitconfig, it will still work normally:


Dunk is my new diff pager

Dunk is a beautiful git diff tool built on top of rich.


Git Diff Cached

Basically, if I have just staged changes using git add, then a normal git diff won't show me those changes. It will only show me the changes that have not been staged. So, I add the --cached option:


Git Image Diff with iTerm2

This seems like it should be possible, you can replace what git does when you do a diff of two different binary files. For example, the spaceman-diff package by Zach Holman does this to do a diff of two images as ASCII art.


Today I learned git diff master..feature

Today I learned how to diff between two branches.


Happy Git Diff coding!