git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Bug: git restore --staged --worktree not working in git version 2.26.2.windows.1
@ 2020-04-28  9:01 Harri Mehtälä
  2020-05-01  8:42 ` Eric Sunshine
  0 siblings, 1 reply; 2+ messages in thread
From: Harri Mehtälä @ 2020-04-28  9:01 UTC (permalink / raw)
  To: git@vger.kernel.org

Hello

In git version 2.26.2.windows.1

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 status 
On branch ...
Your branch is up to date with ...

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        modified:   pom.xml

$ git restore --staged --worktree pom.xml

$ git status
On branch ...
Your branch is up to date with ...

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        modified:   pom.xml
______________________

It looks like currently I have to do both separately. 

- Harri Mehtälä

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Bug: git restore --staged --worktree not working in git version 2.26.2.windows.1
  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
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Sunshine @ 2020-05-01  8:42 UTC (permalink / raw)
  To: Harri Mehtälä; +Cc: git@vger.kernel.org

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/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-05-01  8:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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

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).