What to do when git diff is not showing anything

Kenny DuMez
Kenny DuMez
Graphite software engineer


Note

This guide explains this concept in vanilla Git. For Graphite documentation, see our CLI docs.


This guide will walk you through various scenarios where git diff is not providing the output you expect, and walk through solutions to ensure you can successfully view differences in your Git files.

git diff is a powerful Git command used to show the differences between Git objects such as commits, branches, and tags. It can also show changes between your local code and code hosted in a remote server, and can be used to compare different versions of the same file.

  1. No changes detected: If there are no differences between the compared entities (e.g., files, commits, branches), git diff will still run successfully but not show any output.
  2. Untracked files: git diff does not list untracked files (new files that are not yet added to the staging area, or files explicitly ignored by Git, such as those listed in the .gitignore file).

Verify that there are indeed changes:

  • Check the status of your repository using:
    Terminal
    git status
    This command shows the state of the working directory, the space where files are checked out for you to edit and work on, and the staging area, the layer where Git prepares changes before they are committed to the repository. It lets you see which changes have been staged, which haven't, and which files are being tracked by Git.

To include new files (untracked files) in the diff:

  • Use the --include-untracked or -N option with git diff:
    Terminal
    git diff --include-untracked
    This command will show the diff of new files that have not been added to the staging area.

If you've staged the changes, git diff will not show any output because by default the command only compares your working directory with the index (staging area):

  • To see staged changes, you need to compare the staging area with your last commit:
    Terminal
    git diff --staged
    This command will show what has been staged but not yet committed.

Ensure that any specific paths or filenames are correctly spelled:

If you specify a path or filename, double-check them for any typos.

Check if there is any configuration that might be affecting the output:

  • Check Git configurations that might hide certain changes:
    Terminal
    git config --list
    Look for configurations like diff.ignoreSubmodules or other diff-related settings.

If after following these steps git diff is still behaving unexpectedly, see the official Git documentation for additional troubleshooting.

Graphite
Git stacked on GitHub

Stacked pull requests are easier to read, easier to write, and easier to manage.
Teams that stack ship better software, faster.

Or install our CLI.
Product Screenshot 1
Product Screenshot 2