Make "git diff" look beautiful in the terminal
If you’re working with Git often in the terminal, you might have noticed that the git diff
command is not very pretty when displaying unstaged changes.
The output that the git diff
command gives is good for a file or two with minimal changes but when there is a plethora of files with a lot of changes, it can be a bit overwhelming.
Here’s what a typical git diff
output looks like.
The output can be improved significantly by using a package called git-delta which enhances the
git diff
command to give a more refined output just like how you see in a graphical editor like VS Code.
To use this package, all you need is to install it on your system.
If you use macOS or Linux, you can install it using Homebrew like so.
brew install delta
Once installed, open the ~/.gitconfig
file and add the following.
[core]
pager = delta
This specifies that the git diff
command should use the delta
pager.
Now, when you run git diff
, you’ll get a beautiful output that you can easily parse.
You can get the diff in the side-by-side style as well. To do so, add the following to the ~/.gitconfig
file.
[delta]
side-by-side = true
Now, when you run git diff
, you’ll get a side-by-side diff like so.
You can also add configurations to see line numbers, merge conflicts, and more.
For more information, check out the git-delta documentation.
Like this article?
Buy me a coffee👋 Hi there! I'm Amit. I write articles about all things web development. You can become a sponsor on my blog to help me continue my writing journey and get your brand in front of thousands of eyes.