{"thread":{"id":"57004","subject":"`git diff` after `git checkout from-branch -- files` reports nothing","startedAt":"2021-11-30T20:49:50Z","lastAt":"2021-11-30T23:34:42Z","messageCount":3,"participants":["Noel Yap","Bryan Turner"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"442679","messageId":"CALa_nQ=Q1h9b_BZcg9AeJurLeRpGrpUFuyoMz-DYKB3bgFJj4Q@mail.gmail.com","threadId":"57004","inReplyTo":null,"subject":"`git diff` after `git checkout from-branch -- files` reports nothing","fromName":"Noel Yap","fromEmail":"noel.yap@gmail.com","sentAt":"2021-11-30T20:48:46Z","receivedAt":"2021-11-30T20:49:50Z","isPatch":false,"sender":{"key":"noel.yap@gmail.com","avatar":null},"body":"Thank you for filling out a Git bug report!\nPlease answer the following questions to help us understand your issue.\n\nWhat did you do before the bug happened? (Steps to reproduce your issue)\n\n`git checkout -b to-branch; git checkout from-branch -- filenames; git\nstatus; git diff`\n\nWhat did you expect to happen? (Expected behavior)\n\n`git status` expected to show updated files and `git diff` expected to\nshow file changes.\n\nWhat happened instead? (Actual behavior)\n\n`git status` showed updated files but `git diff` showed no file changes.\n\nWhat's different between what you expected and what actually happened?\n\n`git diff` was expected to show file changes but it showed nothing instead.\n\nAnything else you want to add:\n\nIf I `git reset -q HEAD -- filenames`, `git diff` starts showing file changes.\n\nPlease review the rest of the bug report below.\nYou can delete any lines you don't wish to share.\n\n\n[System Info]\ngit version:\ngit version 2.34.1\ncpu: x86_64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nuname: Linux 5.11.0-36-generic #40~20.04.1-Ubuntu SMP Sat Sep 18\n02:14:19 UTC 2021 x86_64\ncompiler info: gnuc: 9.3\nlibc info: glibc: 2.31\n$SHELL (typically, interactive shell): /bin/bash\n\n\n[Enabled Hooks]\napplypatch-msg\ncommit-msg\npost-applypatch\npost-checkout\npost-commit\npost-merge\npost-receive\npost-rewrite\npost-update\npre-applypatch\npre-auto-gc\npre-commit\npre-merge-commit\npre-push\npre-rebase\npre-receive\nprepare-commit-msg\npush-to-checkout\nsendemail-validate\nupdate\n"},{"id":"442707","messageId":"CAGyf7-Ea719UNEAQSTeeSYyCcsqMo5TWXR+dSr8sDqDfj+tLAA@mail.gmail.com","threadId":"57004","inReplyTo":"CALa_nQ=Q1h9b_BZcg9AeJurLeRpGrpUFuyoMz-DYKB3bgFJj4Q@mail.gmail.com","subject":"Re: `git diff` after `git checkout from-branch -- files` reports nothing","fromName":"Bryan Turner","fromEmail":"bturner@atlassian.com","sentAt":"2021-11-30T21:39:20Z","receivedAt":"2021-11-30T21:39:38Z","isPatch":false,"sender":{"key":"bturner@atlassian.com","avatar":"https://gravatar.com/avatar/16bcf3167981c1ef7c804e502642366d888a35b0d0b0a4ca01fdc442aa1acb1e?d=mp&s=160"},"body":"On Tue, Nov 30, 2021 at 12:49 PM Noel Yap <noel.yap@gmail.com> wrote:\n>\n> Thank you for filling out a Git bug report!\n> Please answer the following questions to help us understand your issue.\n>\n> What did you do before the bug happened? (Steps to reproduce your issue)\n>\n> `git checkout -b to-branch; git checkout from-branch -- filenames; git\n> status; git diff`\n\n\"git diff\" as run here by default only shows _unstaged_ changes. Since\nyou ran \"git checkout from-branch -- filenames\", those changes were\n_staged_. That means you'd need \"git diff --cached\" or \"git diff\n--staged\" to see them.\n>\n> What did you expect to happen? (Expected behavior)\n>\n> `git status` expected to show updated files and `git diff` expected to\n> show file changes.\n>\n> What happened instead? (Actual behavior)\n>\n> `git status` showed updated files but `git diff` showed no file changes.\n\n\"git status\" compares the working copy to the index, so it will always\nshow the changes, but it has 2 different blocks, staged and unstaged\nchanges. If your changes appear in the staged block, you need \"git\ndiff --cached\" or \"git diff --staged\". If they're in the unstaged\nblock, they'll be visible in \"git diff\".\n\n>\n> What's different between what you expected and what actually happened?\n>\n> `git diff` was expected to show file changes but it showed nothing instead.\n>\n> Anything else you want to add:\n>\n> If I `git reset -q HEAD -- filenames`, `git diff` starts showing file changes.\n\nThis unstaged the changes, at which point they show in a plain \"git\ndiff\". They also would move from the staged block to the unstaged\nblock in your \"git status\" output.\n\nAs far as I can tell everything is working as intended.\n\nHope this helps,\nBryan Turner\n\n>\n> Please review the rest of the bug report below.\n> You can delete any lines you don't wish to share.\n>\n>\n> [System Info]\n> git version:\n> git version 2.34.1\n> cpu: x86_64\n> no commit associated with this build\n> sizeof-long: 8\n> sizeof-size_t: 8\n> shell-path: /bin/sh\n> uname: Linux 5.11.0-36-generic #40~20.04.1-Ubuntu SMP Sat Sep 18\n> 02:14:19 UTC 2021 x86_64\n> compiler info: gnuc: 9.3\n> libc info: glibc: 2.31\n> $SHELL (typically, interactive shell): /bin/bash\n>\n>\n> [Enabled Hooks]\n> applypatch-msg\n> commit-msg\n> post-applypatch\n> post-checkout\n> post-commit\n> post-merge\n> post-receive\n> post-rewrite\n> post-update\n> pre-applypatch\n> pre-auto-gc\n> pre-commit\n> pre-merge-commit\n> pre-push\n> pre-rebase\n> pre-receive\n> prepare-commit-msg\n> push-to-checkout\n> sendemail-validate\n> update\n"},{"id":"442719","messageId":"CALa_nQmTeE9fDFN_=F4YwY-A=BQRpB_twh-X3Fw1ks=8UGNs9g@mail.gmail.com","threadId":"57004","inReplyTo":"CAGyf7-Ea719UNEAQSTeeSYyCcsqMo5TWXR+dSr8sDqDfj+tLAA@mail.gmail.com","subject":"Re: `git diff` after `git checkout from-branch -- files` reports nothing","fromName":"Noel Yap","fromEmail":"noel.yap@gmail.com","sentAt":"2021-11-30T23:34:12Z","receivedAt":"2021-11-30T23:34:42Z","isPatch":false,"sender":{"key":"noel.yap@gmail.com","avatar":null},"body":"I didn't know this about `git diff`. Thanks for the info!\n\nOn Tue, Nov 30, 2021 at 1:39 PM Bryan Turner <bturner@atlassian.com> wrote:\n>\n> On Tue, Nov 30, 2021 at 12:49 PM Noel Yap <noel.yap@gmail.com> wrote:\n> >\n> > Thank you for filling out a Git bug report!\n> > Please answer the following questions to help us understand your issue.\n> >\n> > What did you do before the bug happened? (Steps to reproduce your issue)\n> >\n> > `git checkout -b to-branch; git checkout from-branch -- filenames; git\n> > status; git diff`\n>\n> \"git diff\" as run here by default only shows _unstaged_ changes. Since\n> you ran \"git checkout from-branch -- filenames\", those changes were\n> _staged_. That means you'd need \"git diff --cached\" or \"git diff\n> --staged\" to see them.\n> >\n> > What did you expect to happen? (Expected behavior)\n> >\n> > `git status` expected to show updated files and `git diff` expected to\n> > show file changes.\n> >\n> > What happened instead? (Actual behavior)\n> >\n> > `git status` showed updated files but `git diff` showed no file changes.\n>\n> \"git status\" compares the working copy to the index, so it will always\n> show the changes, but it has 2 different blocks, staged and unstaged\n> changes. If your changes appear in the staged block, you need \"git\n> diff --cached\" or \"git diff --staged\". If they're in the unstaged\n> block, they'll be visible in \"git diff\".\n>\n> >\n> > What's different between what you expected and what actually happened?\n> >\n> > `git diff` was expected to show file changes but it showed nothing instead.\n> >\n> > Anything else you want to add:\n> >\n> > If I `git reset -q HEAD -- filenames`, `git diff` starts showing file changes.\n>\n> This unstaged the changes, at which point they show in a plain \"git\n> diff\". They also would move from the staged block to the unstaged\n> block in your \"git status\" output.\n>\n> As far as I can tell everything is working as intended.\n>\n> Hope this helps,\n> Bryan Turner\n>\n> >\n> > Please review the rest of the bug report below.\n> > You can delete any lines you don't wish to share.\n> >\n> >\n> > [System Info]\n> > git version:\n> > git version 2.34.1\n> > cpu: x86_64\n> > no commit associated with this build\n> > sizeof-long: 8\n> > sizeof-size_t: 8\n> > shell-path: /bin/sh\n> > uname: Linux 5.11.0-36-generic #40~20.04.1-Ubuntu SMP Sat Sep 18\n> > 02:14:19 UTC 2021 x86_64\n> > compiler info: gnuc: 9.3\n> > libc info: glibc: 2.31\n> > $SHELL (typically, interactive shell): /bin/bash\n> >\n> >\n> > [Enabled Hooks]\n> > applypatch-msg\n> > commit-msg\n> > post-applypatch\n> > post-checkout\n> > post-commit\n> > post-merge\n> > post-receive\n> > post-rewrite\n> > post-update\n> > pre-applypatch\n> > pre-auto-gc\n> > pre-commit\n> > pre-merge-commit\n> > pre-push\n> > pre-rebase\n> > pre-receive\n> > prepare-commit-msg\n> > push-to-checkout\n> > sendemail-validate\n> > update\n"}]}