Quick Tip: How to Hide Whitespace Changes in Git Diffs

Quick Tip: How to Hide Whitespace Changes in Git Diffs

At 4/19/2024

Screenshot of a code diff before and after hiding whitespace.

If you’ve ever had to review a pull request where the only code change is adding or removing a wrapper element, you’ll be familiar with the pain of reviewing what appears to be a massive change but is actually trivial.

In this example I’ve added a wrapper element and removed some inner elements. By default, it looks like I changed almost every line. That’s because git is highlighting every line that had an indentation change. When I hide whitespace changes, it becomes quite clear what I added and removed.

Most Git hosting services support the ability to hide whitespace changes by adding ?w=1 as a URL parameter. Let’s explore how to hide whitespace changes for some of the big players.

You can hide whitespace changes for GitHub diffs in two ways. First, click the gear icon near the top of the page and check the “Hide whitespace changes” option.

Screenshot of the GitHub UI, showing the "hide whitespace changes" option.

Or, you can add ?w=1 to the URL.

You can hide whitespace changes for GitLab diffs in two ways. First, click the “Hide whitespace changes” button near the top of the page.

Screenshot of the GitLab UI, showing the "hide whitespace changes" button.

Or, you can add ?w=1 to the URL.

You can hide whitespace changes for Bitbucket diffs by adding ?w=1 to the URL.

حقوق التأليف والنشر

نحن نحترم حقوق الملكية للآخرين ونحرص دائمًا على عدم التعدي على حقوقهم، لذا يحق للمؤلفين ودور النشر المطالبة بإزالة رابط تحميل مقال أو كتاب من الموقع. إذا وجدت مقالاً أو كتاباً خاصاً بك ولم توافق على نشر رابط التحميل أو كان لديك اقتراح أو شكوى راسلنا عبر تواصل معنا, أو عن طريق البريد الإلكتروني في: support@freewsad.com.

المزيد عنا