{"id":30296,"date":"2023-01-14T11:29:17","date_gmt":"2023-01-14T05:59:17","guid":{"rendered":"https:\/\/jassweb.com\/solved\/solved-why-does-output-differ-under-git-diff-vs-git-diff-staged\/"},"modified":"2023-01-14T11:29:17","modified_gmt":"2023-01-14T05:59:17","slug":"solved-why-does-output-differ-under-git-diff-vs-git-diff-staged","status":"publish","type":"post","link":"https:\/\/jassweb.com\/solved\/solved-why-does-output-differ-under-git-diff-vs-git-diff-staged\/","title":{"rendered":"[Solved] Why does output differ under git diff vs. git diff &#8211;staged?"},"content":{"rendered":"<p> [ad_1]<br \/>\n<\/p>\n<div id=\"answer-53907412\" class=\"answer js-answer accepted-answer js-accepted-answer\" data-answerid=\"53907412\" data-parentid=\"53904756\" data-score=\"4\" data-position-on-page=\"1\" data-highest-scored=\"1\" data-question-has-accepted-highest-score=\"1\" itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n<div class=\"post-layout\">\n<div class=\"votecell post-layout--left\"><\/div>\n<div class=\"answercell post-layout--right\">\n<div class=\"s-prose js-post-body\" itemprop=\"text\">\n<p>You are, I think, being misled.  Git doesn&#8217;t store <em>changes<\/em> at all.  The whole thing seems very mysterious until you realize that Git just stores everything intact, but does so in a weird way.<\/p>\n<h3>What Git stores permanently<\/h3>\n<p>First and most important, Git doesn&#8217;t exactly store <em>files<\/em>.  It winds up doing so, but that&#8217;s because Git stores <em>commits<\/em>, and each individual commit contains (all!) the files.  That is, at some earlier point during development, you\u2014or someone\u2014told Git: <em>Here&#8217;s this entire file-tree, some set of folders \/ directories containing files and sub-directories that contain more files and sub-directories and so on.  Make a snapshot of how they all look right now.<\/em>  That snapshot, that entire copy of everything, goes into a new commit.<\/p>\n<p>Next, commits, once made, are mostly permanent, and completely, totally, 100% read-only.  You cannot change anything that&#8217;s inside a commit.  You can just think of them as permanent: the only time a commit can truly go away is if you carefully arrange to make sure that no one\u2014not yourself, nor anyone else\u2014can <em>find<\/em> it later, using <code>git reset<\/code> or similar tools.<\/p>\n<p>For many reasons, including not having the repository get enormously fat if you make many commits that keep re-using most of the old versions of most files, the files that are stored inside commits are kept in a special, compressed, Git-only format.  Since the files inside commits are frozen, if new commit <em>C9<\/em> is just like its previous commit <em>C8<\/em> except for one file, the two commits will <em>share<\/em> all the identical files, too.<\/p>\n<h3>What Git lets you work with, temporarily<\/h3>\n<p>Since you can&#8217;t <em>change<\/em> any commit, at all, ever, Git would be useless if it did not have a way to <em>extract<\/em> all the files from some commit.  Extracting a commit copies all of its files out of the deep-freeze, and then de-compresses the files and turns them back into ordinary, every-day files that you and your computer can work with.  These files are <em>copies<\/em> of what was in that Git commit, but here, in this work area\u2014the <em>work-tree<\/em> or <em>working tree<\/em>\u2014they&#8217;re useful to you and your computer, <em>and<\/em> you can change them any way you like.<\/p>\n<h3>Git complicates things with its index<\/h3>\n<p>Now comes the tricky bit.  Other version control systems may stop here: they too have commits, that save the files forever in frozen form, and a work-tree, that let you work on the files in ordinary form.  To make a new commit, those other version control systems slowly, painfully, one by one, take each work-tree file, compress it down to get it ready for freezing, and <em>then<\/em> check to see if that frozen file will be the same as the old one.  If so, they can re-use the old file!  If not, they do whatever it takes to save away the new file.  This is terribly slow, and there are various ways to speed it up, which they do use in general, but in these non-Git version control systems, after using their &#8220;commit&#8221; command, you can often get up and go get coffee, or go for a walk or have lunch or something.<\/p>\n<p>Git does something radically different, and this is how <code>git commit<\/code> is so fast, compared to those other systems.  When Git is taking files out of the deep-freeze to put into your work-tree, Git keeps a sort of semi-frozen\u2014&#8221;slushy&#8221;, if you will\u2014copy of <em>every file<\/em>, ready to go into the <em>next<\/em> commit.  Initially, these copies all match the frozen commit copy.<\/p>\n<p>These sort-of-slushy copies of files are in what Git calls, variously, the <em>index<\/em>, the <em>staging area<\/em>, or the <em>cache<\/em>, depending on who or what part of Git is doing the calling.  The key difference between these index copies of every file, and the frozen copy in the current commit, is that the committed copies really are frozen.  They <em>can&#8217;t<\/em> be changed.  The index copies are only <em>almost<\/em> frozen: they <em>can<\/em> be changed, by writing a new file into the index in place of that old one.<\/p>\n<p>What this means, in the end, is that for every file in the commit, you wind up with not two but <em>three<\/em> active copies, when you tell Git to make that commit be the current commit, using <code>git checkout <em>somebranch<\/em><\/code>.  (This checkout selects <em><code>somebranch<\/code><\/em> as the current <em>branch name<\/em> and therefore also extracts what Git calls its <em>tip commit<\/em> to be the <em>current<\/em> commit.  There&#8217;s always a name for this current commit: Git calls it <code>HEAD<\/code>.)  Suppose, for instance, that the tip commit of <code>master<\/code> has two files, named <code>README.md<\/code> and <code>main.py<\/code>:<\/p>\n<pre><code>   HEAD           index         work-tree\n---------       ---------       ---------\nREADME.md       README.md       README.md\nmain.py         main.py         main.py\n<\/code><\/pre>\n<p>At this point, <em>all three copies of each file match each other<\/em>.  That is, all three <code>README.md<\/code>s are the same, except in terms of their format: the one in <code>HEAD<\/code> is frozen and Git-only; the one in the index is semi-frozen and Git-only; and the one in your work-tree is usable and useful to you; but all three represent the same <em>file contents<\/em>.  The same goes for the three copies of <code>main.py<\/code>.<\/p>\n<p>Now suppose you change one (or both) of the work-tree files.  For instance, suppose you change your work-tree <code>README.md<\/code>.  Let&#8217;s mark it with a <code>(2)<\/code> to indicate that it&#8217;s different, and mark the old ones with <code>(1)<\/code> to remember which the old ones were:<\/p>\n<pre><code>    HEAD            index         work-tree\n------------    ------------    ------------\nREADME.md(1)    README.md(1)    README.md(2)\nmain.py(1)      main.py(1)      main.py(1)\n<\/code><\/pre>\n<p>You can now ask Git to <em>compare<\/em> the index copies of every file to the work-tree copies of every file, and this time, you&#8217;ll see your <em>change<\/em> to <code>README.md<\/code>.<\/p>\n<p>When you run <code>git add<\/code>, you are really telling Git: <em>Take the work-tree copy of the files I&#8217;m adding, and prepare them for freezing.<\/em>  Git will copy the work-tree copy of <code>README.md<\/code> or <code>main.py<\/code> (or both) back into the index, Git-ifying the contents, getting them ready for the next freeze:<\/p>\n<pre><code>    HEAD            index         work-tree\n------------    ------------    ------------\nREADME.md(1)    README.md(2)    README.md(2)\nmain.py(1)      main.py(1)      main.py(1)\n<\/code><\/pre>\n<p>This time, asking Git to compare the <em>index<\/em> copy (of everything) to the <em>work-tree<\/em> copy (of everything) shows nothing!  They are the same, after all.  To see a difference, you must ask Git to compare the <code>HEAD<\/code> commit to the index, or the <code>HEAD<\/code> commit to the work-tree.  Either will suffice right now, because <em>right now<\/em> the index and work-tree match again.<\/p>\n<p>Note, however, that you can change the work-tree copy <em>again<\/em> after you use <code>git add<\/code>.  Suppose you modify <code>README.md<\/code> one more time, giving:<\/p>\n<pre><code>    HEAD            index         work-tree\n------------    ------------    ------------\nREADME.md(1)    README.md(2)    README.md(3)\nmain.py(1)      main.py(1)      main.py(1)\n<\/code><\/pre>\n<p>Now all three copies of <code>main.py<\/code> match, but all three copies of <code>README.md<\/code> are different.  So now it matters whether you have Git compare <code>HEAD<\/code> vs index, or <code>HEAD<\/code> vs work-tree, or index vs work-tree: each will show a <em>different change<\/em> to <code>README.md<\/code>.<\/p>\n<h3>Git makes <em>new<\/em> commits from the index<\/h3>\n<p>When and if you do choose to make a new commit\u2014a new permanent snapshot of all the files as they stand <em>now<\/em>\u2014Git makes the new commit&#8217;s snapshot using the semi-frozen files in the index.  All that the commit verb has to do with them is finish the freezing process (which, at a technical level, consists of making <em>tree<\/em> objects to hold them, but you don&#8217;t need to know this).  So <code>git commit<\/code> collects your name, email, the time, your log message, and the current commit&#8217;s hash ID, freezes the index, and puts all of those together into a new commit.  The new commit <em>becomes<\/em> the <code>HEAD<\/code> commit, so that now <code>HEAD<\/code> refers to the <em>new<\/em> commit.  If the old commit was <em>C8<\/em> and the new one is <em>C9<\/em>, <code>HEAD<\/code> used to mean <em>C8<\/em>, but now it means <em>C9<\/em>.<\/p>\n<p>Once that commit finishes, the <code>HEAD<\/code> and index copies of every file <em>automatically match<\/em>.  It&#8217;s obvious that they must, since the new <code>HEAD<\/code> was made <em>from<\/em> the index.  So if you make that new commit with the index holding the middle version of <code>README.md<\/code>, you get:<\/p>\n<pre><code>    HEAD            index         work-tree\n------------    ------------    ------------\nREADME.md(2)    README.md(2)    README.md(3)\nmain.py(1)      main.py(1)      main.py(1)\n<\/code><\/pre>\n<p>Note that Git completely ignored the work-tree during this process!  There&#8217;s a way to tell <code>git commit<\/code> that it should look at the work-tree and <em>automatically<\/em> run <code>git add<\/code>, but let&#8217;s leave that for later.<\/p>\n<p>The summary of this particular section is that a good way to think of the index is: <strong>The index contains the <em>next<\/em> commit you propose to make.<\/strong>  The <code>git add<\/code> command means: <em>Update my proposed next commit.<\/em>  This explains why you have to <code>git add<\/code> all the time.<\/p>\n<h3>Git&#8217;s <code>diff<\/code> verb<\/h3>\n<p>Because there <em>are<\/em> these three simultaneous, active copies of each file\u2014one permanent, one proposed for the <em>next<\/em> commit, and one that you can actually see and work with\u2014Git needs a way to <em>compare<\/em> these things.  The <code>diff<\/code> verb is how you ask Git to compare two things, and its options are how you select <em>which<\/em> two things to compare:<\/p>\n<ul>\n<li>\n<p><code>git diff <em>commit-A commit-B<\/em><\/code> tells Git: <em>Extract the snapshot in commit A to a temporary area; extract the snapshot in commit B to a temporary area, and then compare them and show me what&#8217;s different.<\/em>  This is useful in general, but not so much when making a <em>new<\/em> commit, since it&#8217;s about existing, frozen, unchangeable commits.<\/p>\n<\/li>\n<li>\n<p><code>git diff<\/code>\u2014with no options or commit specifiers at all\u2014tells Git: <em>Compare the index to the work-tree.<\/em>  Git does not look at any actual commit, it just looks at the index\u2014the <em>proposed<\/em> next commit\u2014and compares to your usable copies of files.  Whenever something is different, you <em>could<\/em> use <code>git add<\/code> to copy it into the index.  So this tells you what you could <code>git add<\/code>, if you wanted.<\/p>\n<\/li>\n<li>\n<p><code>git diff --cached<\/code> or <code>git diff --staged<\/code>\u2014the options have exactly the same meaning\u2014tells Git: <em>Compare the <code>HEAD<\/code> commit to the index.<\/em>  This time, Git does not look at your work-tree at all.  It just finds out what&#8217;s different between the <em>current commit<\/em> and the <em>proposed next commit<\/em>.  That is, this is what would be <em>different<\/em> if you committed right now.<\/p>\n<\/li>\n<li>\n<p><code>git diff HEAD<\/code> (or more generally, <code>git diff <em>commit<\/em><\/code>) tells Git: <em>Compare what&#8217;s in the commit I named, such as <code>HEAD<\/code>, to what&#8217;s in the work-tree.<\/em>  This time, Git ignores your <em>index<\/em>, and just goes with the specific commit\u2014such as <code>HEAD<\/code>\u2014and the contents of the work-tree.  This is not as useful as the HEAD-vs-index or index-vs-work-tree comparisons, but you can do it if you want.<\/p>\n<\/li>\n<\/ul>\n<p>There are, of course, more ways you might want to compare any two items, so <code>git diff<\/code> has a lot of options.  But these are the main ones of interest at this point.<\/p>\n<h3><code>git status<\/code> runs two <code>git diff<\/code>s<\/h3>\n<p>Note that the two <em>most useful<\/em> <code>git diff<\/code>s above, when you&#8217;re actively developing, are <code>git diff --cached<\/code>, which tells you what <em>would<\/em> be different if you committed <em>right now<\/em>, and <code>git diff<\/code> with no options, which tells you <em>what else could be different<\/em> if you ran <code>git add<\/code> right now.  The <code>git status<\/code> command, which you should use often, runs both of these diffs for you!  It runs them with the <code>--name-status<\/code> flag set, internally, so that instead of showing the actual differences, it just shows the file&#8217;s name if the file is changed.<sup>1<\/sup><\/p>\n<p>Let&#8217;s see that again: <code>git status<\/code> runs <strong>two<\/strong> <code>git diff<\/code> commands.  The first one is <code>git diff --cached<\/code>, i.e., what&#8217;s different in the <em>proposed commit<\/em>.  These are <strong>changes that are staged for commit<\/strong>.  The second is a plain <code>git diff<\/code>, i.e., what&#8217;s different in the index\u2014the proposed commit\u2014and the work-tree.  These are <strong>changes that are not staged for commit.<\/strong><\/p>\n<p>So now you know what <code>git status<\/code> tells you, and when you would want to use <code>git diff<\/code> with or without <code>--staged<\/code> to see more than just the <em>names<\/em> of the files.  Remember that the changes that <code>git diff<\/code> shows you are what Git is <em>figuring out:<\/em> the files inside the index, or in the work-tree, are full, complete copies.  They just may be different from each other and\/or different from the full, complete copy in <code>HEAD<\/code>.<\/p>\n<hr>\n<p><sup>1<\/sup>The &#8220;status&#8221; part of <code>--name-status<\/code> can instead say that a file is <em>added<\/em>\u2014is in the index, but not in the <code>HEAD<\/code> commit, for instance.  Or, in some cases, it can say that a file is renamed or has had some other auxiliary change, but let&#8217;s not get into this here.<\/p>\n<\/p><\/div>\n<div class=\"mt24\"><\/div>\n<\/div>\n<p>            <span class=\"d-none\" itemprop=\"commentCount\">1<\/span> <\/p><\/div>\n<\/div>\n<p>[ad_2]<\/p>\n<p>solved Why does output differ under git diff vs. git diff &#8211;staged? <\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ad_1] You are, I think, being misled. Git doesn&#8217;t store changes at all. The whole thing seems very mysterious until you realize that Git just stores everything intact, but does so in a weird way. What Git stores permanently First and most important, Git doesn&#8217;t exactly store files. It winds up doing so, but that&#8217;s &#8230; <a title=\"[Solved] Why does output differ under git diff vs. git diff &#8211;staged?\" class=\"read-more\" href=\"https:\/\/jassweb.com\/solved\/solved-why-does-output-differ-under-git-diff-vs-git-diff-staged\/\" aria-label=\"More on [Solved] Why does output differ under git diff vs. git diff &#8211;staged?\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[320],"tags":[329,5727],"class_list":["post-30296","post","type-post","status-publish","format-standard","hentry","category-solved","tag-git","tag-git-diff"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>[Solved] Why does output differ under git diff vs. git diff -staged? - JassWeb<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jassweb.com\/solved\/solved-why-does-output-differ-under-git-diff-vs-git-diff-staged\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[Solved] Why does output differ under git diff vs. git diff -staged? - JassWeb\" \/>\n<meta property=\"og:description\" content=\"[ad_1] You are, I think, being misled. Git doesn&#8217;t store changes at all. The whole thing seems very mysterious until you realize that Git just stores everything intact, but does so in a weird way. What Git stores permanently First and most important, Git doesn&#8217;t exactly store files. It winds up doing so, but that&#8217;s ... Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jassweb.com\/solved\/solved-why-does-output-differ-under-git-diff-vs-git-diff-staged\/\" \/>\n<meta property=\"og:site_name\" content=\"JassWeb\" \/>\n<meta property=\"article:published_time\" content=\"2023-01-14T05:59:17+00:00\" \/>\n<meta name=\"author\" content=\"Kirat\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kirat\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/solved-why-does-output-differ-under-git-diff-vs-git-diff-staged\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/solved-why-does-output-differ-under-git-diff-vs-git-diff-staged\\\/\"},\"author\":{\"name\":\"Kirat\",\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/#\\\/schema\\\/person\\\/65c9c7b7958150c0dc8371fa35dd7c31\"},\"headline\":\"[Solved] Why does output differ under git diff vs. git diff &#8211;staged?\",\"datePublished\":\"2023-01-14T05:59:17+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/solved-why-does-output-differ-under-git-diff-vs-git-diff-staged\\\/\"},\"wordCount\":1956,\"publisher\":{\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/#organization\"},\"keywords\":[\"git\",\"git-diff\"],\"articleSection\":[\"Solved\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/solved-why-does-output-differ-under-git-diff-vs-git-diff-staged\\\/\",\"url\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/solved-why-does-output-differ-under-git-diff-vs-git-diff-staged\\\/\",\"name\":\"[Solved] Why does output differ under git diff vs. git diff -staged? - JassWeb\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/#website\"},\"datePublished\":\"2023-01-14T05:59:17+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/solved-why-does-output-differ-under-git-diff-vs-git-diff-staged\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/jassweb.com\\\/solved\\\/solved-why-does-output-differ-under-git-diff-vs-git-diff-staged\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/solved-why-does-output-differ-under-git-diff-vs-git-diff-staged\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[Solved] Why does output differ under git diff vs. git diff &#8211;staged?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/#website\",\"url\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/\",\"name\":\"JassWeb\",\"description\":\"Build High-quality Websites\",\"publisher\":{\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/#organization\",\"name\":\"Jass Web\",\"url\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/jassweb.com\\\/wp-content\\\/uploads\\\/2021\\\/02\\\/jass-website-logo-1.png\",\"contentUrl\":\"https:\\\/\\\/jassweb.com\\\/wp-content\\\/uploads\\\/2021\\\/02\\\/jass-website-logo-1.png\",\"width\":693,\"height\":132,\"caption\":\"Jass Web\"},\"image\":{\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/#\\\/schema\\\/person\\\/65c9c7b7958150c0dc8371fa35dd7c31\",\"name\":\"Kirat\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/wp-content\\\/litespeed\\\/avatar\\\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1777613206\",\"url\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/wp-content\\\/litespeed\\\/avatar\\\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1777613206\",\"contentUrl\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/wp-content\\\/litespeed\\\/avatar\\\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1777613206\",\"caption\":\"Kirat\"},\"sameAs\":[\"http:\\\/\\\/jassweb.com\"],\"url\":\"https:\\\/\\\/jassweb.com\\\/solved\\\/author\\\/jaspritsinghghumangmail-com\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[Solved] Why does output differ under git diff vs. git diff -staged? - JassWeb","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jassweb.com\/solved\/solved-why-does-output-differ-under-git-diff-vs-git-diff-staged\/","og_locale":"en_US","og_type":"article","og_title":"[Solved] Why does output differ under git diff vs. git diff -staged? - JassWeb","og_description":"[ad_1] You are, I think, being misled. Git doesn&#8217;t store changes at all. The whole thing seems very mysterious until you realize that Git just stores everything intact, but does so in a weird way. What Git stores permanently First and most important, Git doesn&#8217;t exactly store files. It winds up doing so, but that&#8217;s ... Read more","og_url":"https:\/\/jassweb.com\/solved\/solved-why-does-output-differ-under-git-diff-vs-git-diff-staged\/","og_site_name":"JassWeb","article_published_time":"2023-01-14T05:59:17+00:00","author":"Kirat","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Kirat","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jassweb.com\/solved\/solved-why-does-output-differ-under-git-diff-vs-git-diff-staged\/#article","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/solved-why-does-output-differ-under-git-diff-vs-git-diff-staged\/"},"author":{"name":"Kirat","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31"},"headline":"[Solved] Why does output differ under git diff vs. git diff &#8211;staged?","datePublished":"2023-01-14T05:59:17+00:00","mainEntityOfPage":{"@id":"https:\/\/jassweb.com\/solved\/solved-why-does-output-differ-under-git-diff-vs-git-diff-staged\/"},"wordCount":1956,"publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"keywords":["git","git-diff"],"articleSection":["Solved"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/jassweb.com\/solved\/solved-why-does-output-differ-under-git-diff-vs-git-diff-staged\/","url":"https:\/\/jassweb.com\/solved\/solved-why-does-output-differ-under-git-diff-vs-git-diff-staged\/","name":"[Solved] Why does output differ under git diff vs. git diff -staged? - JassWeb","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/#website"},"datePublished":"2023-01-14T05:59:17+00:00","breadcrumb":{"@id":"https:\/\/jassweb.com\/solved\/solved-why-does-output-differ-under-git-diff-vs-git-diff-staged\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jassweb.com\/solved\/solved-why-does-output-differ-under-git-diff-vs-git-diff-staged\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jassweb.com\/solved\/solved-why-does-output-differ-under-git-diff-vs-git-diff-staged\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/jassweb.com\/solved\/"},{"@type":"ListItem","position":2,"name":"[Solved] Why does output differ under git diff vs. git diff &#8211;staged?"}]},{"@type":"WebSite","@id":"https:\/\/jassweb.com\/solved\/#website","url":"https:\/\/jassweb.com\/solved\/","name":"JassWeb","description":"Build High-quality Websites","publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jassweb.com\/solved\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/jassweb.com\/solved\/#organization","name":"Jass Web","url":"https:\/\/jassweb.com\/solved\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/","url":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","contentUrl":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","width":693,"height":132,"caption":"Jass Web"},"image":{"@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31","name":"Kirat","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1777613206","url":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1777613206","contentUrl":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1777613206","caption":"Kirat"},"sameAs":["http:\/\/jassweb.com"],"url":"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/"}]}},"_links":{"self":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/30296","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/comments?post=30296"}],"version-history":[{"count":0,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/30296\/revisions"}],"wp:attachment":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/media?parent=30296"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/categories?post=30296"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/tags?post=30296"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}