![Forrest logo](/images/logo.png)
git-diff:tldr:66485
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
orgit 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.