Title: How git diff compares your files, the staging area and any two commits
Open Graph Title: How git diff compares your files, the staging area and any two commits
X Title: How git diff compares your files, the staging area and any two commits
Description: git diff shows line-by-line changes between your files, the staging area and any commit. Learn to read its output and pick the right comparison.
Open Graph Description: git diff shows line-by-line changes between your files, the staging area and any commit. Learn to read its output and pick the right comparison.
X Description: git diff shows line-by-line changes between your files, the staging area and any commit. Learn to read its output and pick the right comparison.
Mail addresses
jacob@initialcommit.io
jacob@initialcommit.io
Opengraph URL: https://initialcommit.com/learn/git/commands/git-diff
Domain: initialcommit.com
{
"@context": "https://schema.org",
"@type": "TechArticle",
"headline": "git diff: what changed, and compared to what",
"alternativeHeadline": "How git diff compares your files, the staging area and any two commits",
"description": "git diff shows line-by-line changes between your files, the staging area and any commit. Learn to read its output and pick the right comparison.",
"image": ["https:\/\/initialcommit.com\/img\/initialcommit\/git-diff-98d12861.jpg","https:\/\/initialcommit.com\/img\/initialcommit\/git-diff-98d12861-light.jpg"],
"datePublished": "2026-10-02",
"dateModified": "2026-10-14",
"author": {
"@type": "Person",
"name": "Jacob Stopak",
"url": "https:\/\/initialcommit.com\/blog\/author\/jacobstopak",
"sameAs": ["https:\/\/github.com\/initialcommit-com","https:\/\/www.linkedin.com\/in\/jacob-stopak-6361b4b7","https:\/\/x.com\/initcommit","https:\/\/www.instagram.com\/initialcommit","https:\/\/initialcommit.com"]
},
"publisher": {
"@type": "Organization",
"name": "Initial Commit",
"url": "https:\/\/initialcommit.com",
"logo": { "@type": "ImageObject", "url": "https:\/\/initialcommit.com\/img\/initialcommit\/logo.png" }
},
"mainEntityOfPage": "https:\/\/initialcommit.com\/learn\/git\/commands\/git-diff",
"keywords": "git vcs topic:basics",
"inLanguage": "en",
"isAccessibleForFree": true
}
{
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{ "@type": "ListItem", "position": 1, "name": "Home", "item": "https:\/\/initialcommit.com" },
{ "@type": "ListItem", "position": 2, "name": "Learn Git", "item": "https:\/\/initialcommit.com\/learn\/git" },
{ "@type": "ListItem", "position": 3, "name": "Git commands", "item": "https:\/\/initialcommit.com\/learn\/git\/commands" },
{ "@type": "ListItem", "position": 4, "name": "git diff: what changed, and compared to what", "item": "https:\/\/initialcommit.com\/learn\/git\/commands\/git-diff" }
]
}
{
"@context": "https://schema.org",
"@type": "FAQPage",
"mainEntity": [
{
"@type": "Question",
"name": "Why does git diff show nothing when I have changes?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Your changes are probably staged. Plain git diff compares the working directory with the staging area, so after git add it has nothing to report. Run git diff --staged to see staged changes, or git diff HEAD for everything uncommitted."
}
},
{
"@type": "Question",
"name": "What is the difference between git diff --staged and --cached?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Nothing. They are two names for the same option. --staged was added later because it describes what the option does more clearly."
}
},
{
"@type": "Question",
"name": "How do I see the changes on my branch compared to main?",
"acceptedAnswer": {
"@type": "Answer",
"text": "git diff main...your-branch shows only what your branch added since it split from main. Add --stat for the summary."
}
},
{
"@type": "Question",
"name": "How do I see what changed in one file?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Put the path after --: git diff -- path/to/file. It works with every form, for example git diff main...feature -- path/to/file."
}
}
]
}
| None | IE=edge |
| theme-color | #ffffff |
| ic-lesson-total | 16 |
| ic-lesson-paths | /learn/git/levels/git-overview,/learn/git/levels/init-and-config,/learn/git/levels/add-and-commit,/learn/git/levels/log-and-status,/learn/git/levels/clone-and-remote,/learn/git/levels/push-and-pull,/learn/git/levels/branch-and-switch,/learn/git/levels/merge,/learn/git/levels/tag,/learn/git/levels/stash,/learn/git/levels/restore,/learn/git/levels/revert,/learn/git/levels/reset,/learn/git/levels/rebase,/learn/git/levels/detached-head,/learn/git/levels/remove-and-rename |
| ic-lesson | /learn/git/levels/remove-and-rename|Level 16: Remove & rename |
| og:type | article |
| og:site_name | Initial Commit |
| og:image | https://initialcommit.com/img/initialcommit/git-diff-98d12861.jpg |
| og:image:secure_url | https://initialcommit.com/img/initialcommit/git-diff-98d12861.jpg |
| og:updated_time | 2026-10-14 |
| og:article:published_time | 2026-10-02 |
| og:article:modified_time | 2026-10-14 |
| og:article:author | Jacob Stopak |
| og:article:section | Programming |
| og:article:tag | topic:basics |
| twitter:card | summary_large_image |
| twitter:url | https://initialcommit.com/learn/git/commands/git-diff |
| twitter:image | https://initialcommit.com/img/initialcommit/git-diff-98d12861.jpg |
Links:
Viewport: width=device-width, initial-scale=1.0