From: Eric Sunshine <sunshine@sunshineco.com>
To: "Harri Mehtälä" <harri.mehtala@finago.com>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: Bug: git restore --staged --worktree not working in git version 2.26.2.windows.1
Date: Fri, 1 May 2020 04:42:26 -0400 [thread overview]
Message-ID: <CAPig+cTqqHqM6i8JHTLoY8SyCu=WWh1KCH2HCj8VNNxvux-toQ@mail.gmail.com> (raw)
In-Reply-To: <AM6PR09MB298072F9FEB469130EAEB8F18BAC0@AM6PR09MB2980.eurprd09.prod.outlook.com>
On Tue, Apr 28, 2020 at 5:16 AM Harri Mehtälä <harri.mehtala@finago.com> wrote:
> I am trying to do git restore --staged --worktree for a file. I
> understood from the documentation that you can do both.
>
> "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."
>
> $ git restore --staged --worktree pom.xml
> $ git status
> Changes to be committed:
> modified: pom.xml
>
> It looks like currently I have to do both separately.
If you read a bit further in the documentation, it says that you must
specify --source when combining --staged and --worktree, so your "git
restore" invocation is incorrect. Unfortunately, "git restore" is a
bit buggy in this regard since it blindly accepts this invalid
combination of options when it should instead error out. I submitted a
patch series[1] which fixes this shortcoming.
Having to specify --source in this case can be cumbersome if you just
want to restore from HEAD (a reasonable default), so the submitted
patch series[1] also makes --source default to HEAD when --staged and
--worktree are combined.
[1]: https://lore.kernel.org/git/20200501082746.23943-1-sunshine@sunshineco.com/T/
prev parent reply other threads:[~2020-05-01 8:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-28 9:01 Bug: git restore --staged --worktree not working in git version 2.26.2.windows.1 Harri Mehtälä
2020-05-01 8:42 ` Eric Sunshine [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAPig+cTqqHqM6i8JHTLoY8SyCu=WWh1KCH2HCj8VNNxvux-toQ@mail.gmail.com' \
--to=sunshine@sunshineco.com \
--cc=git@vger.kernel.org \
--cc=harri.mehtala@finago.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).