{"thread":{"id":"53340","subject":"Bug: git restore --staged --worktree not working in git version 2.26.2.windows.1","startedAt":"2020-04-28T09:16:21Z","lastAt":"2020-05-01T08:42:42Z","messageCount":2,"participants":["Harri Mehtälä","Eric Sunshine"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"396448","messageId":"AM6PR09MB298072F9FEB469130EAEB8F18BAC0@AM6PR09MB2980.eurprd09.prod.outlook.com","threadId":"53340","inReplyTo":null,"subject":"Bug: git restore --staged --worktree not working in git version 2.26.2.windows.1","fromName":"Harri Mehtälä","fromEmail":"harri.mehtala@finago.com","sentAt":"2020-04-28T09:01:48Z","receivedAt":"2020-04-28T09:16:21Z","isPatch":false,"sender":{"key":"harri.mehtala@finago.com","avatar":null},"body":"Hello\n\nIn git version 2.26.2.windows.1\n\nI am trying to do git restore --staged --worktree for a file. I understood from the documentation that you can do both.\n\n\"Specify the restore location. If neither option is specified, by default the working tree is restored. Specifying --staged will only restore the index. Specifying both restores both.\"\n\n\n______________________\n$ git status \nOn branch ...\nYour branch is up to date with ...\n\nChanges to be committed:\n  (use \"git restore --staged <file>...\" to unstage)\n        modified:   pom.xml\n\n$ git restore --staged --worktree pom.xml\n\n$ git status\nOn branch ...\nYour branch is up to date with ...\n\nChanges to be committed:\n  (use \"git restore --staged <file>...\" to unstage)\n        modified:   pom.xml\n______________________\n\nIt looks like currently I have to do both separately. \n\n- Harri Mehtälä\n"},{"id":"396734","messageId":"CAPig+cTqqHqM6i8JHTLoY8SyCu=WWh1KCH2HCj8VNNxvux-toQ@mail.gmail.com","threadId":"53340","inReplyTo":"AM6PR09MB298072F9FEB469130EAEB8F18BAC0@AM6PR09MB2980.eurprd09.prod.outlook.com","subject":"Re: Bug: git restore --staged --worktree not working in git version 2.26.2.windows.1","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2020-05-01T08:42:26Z","receivedAt":"2020-05-01T08:42:42Z","isPatch":false,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Tue, Apr 28, 2020 at 5:16 AM Harri Mehtälä <harri.mehtala@finago.com> wrote:\n> I am trying to do git restore --staged --worktree for a file. I\n> understood from the documentation that you can do both.\n>\n> \"Specify the restore location. If neither option is specified, by\n> default the working tree is restored. Specifying --staged will only\n> restore the index. Specifying both restores both.\"\n>\n> $ git restore --staged --worktree pom.xml\n> $ git status\n> Changes to be committed:\n>     modified:  pom.xml\n>\n> It looks like currently I have to do both separately.\n\nIf you read a bit further in the documentation, it says that you must\nspecify --source when combining --staged and --worktree, so your \"git\nrestore\" invocation is incorrect. Unfortunately, \"git restore\" is a\nbit buggy in this regard since it blindly accepts this invalid\ncombination of options when it should instead error out. I submitted a\npatch series[1] which fixes this shortcoming.\n\nHaving to specify --source in this case can be cumbersome if you just\nwant to restore from HEAD (a reasonable default), so the submitted\npatch series[1] also makes --source default to HEAD when --staged and\n--worktree are combined.\n\n[1]: https://lore.kernel.org/git/20200501082746.23943-1-sunshine@sunshineco.com/T/\n"}]}