Forrest logo
back to the git tool

git-diff:tldr:66485

git-diff: Show unstaged, uncommitted changes.
$ git diff
try on your machine

The git diff command is used to display the differences between different states of your repository, such as changes between commits, the current working directory, or the staging area.

When you run git diff without any arguments, it will show the unstaged changes between your working directory and the most recent commit. This includes modifications, additions, and deletions of files. The command will display the lines that were added or removed, providing a detailed representation of the changes.

You can also use git diff with different arguments to compare specific states, for example:

  • git diff <commit1> <commit2>: Compares the differences between two specific commits.
  • git diff --staged or git diff --cached: Shows the changes between the staging area and the latest commit.
  • git diff <file>: Displays the changes for a specific file.

git diff is a handy command for reviewing changes and understanding how the codebase has evolved over time. It helps identify what modifications have been made and allows you to decide which changes you want to include in your next commit.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the git tool