# Bug: "git restore --staged" on a newly created repository

2 messages from 2020-05-26 to 2020-05-27. Participants: Xirui Zhao, Jeff King.
Thread: https://gitlist.dev/t/53546

## Xirui Zhao, 2020-05-26 06:18

Subject: Bug: "git restore --staged" on a newly created repository
Message-ID: <1F3FD418-38D2-4A10-A882-666D4327F993@gmail.com>
URL: https://gitlist.dev/e/1F3FD418-38D2-4A10-A882-666D4327F993%40gmail.com

```
Tested on git version 2.27.0-rc1 (latest build from master branch on github) and 2.26.2
`git restore --staged file` on a newly created repository outputs error "fatal: could not resolve HEAD", but `git reset file` correctly unstages the file.
```

## Jeff King, 2020-05-27 07:32

Subject: Re: Bug: "git restore --staged" on a newly created repository
Message-ID: <20200527073205.GC4006199@coredump.intra.peff.net>
URL: https://gitlist.dev/e/20200527073205.GC4006199%40coredump.intra.peff.net
In-Reply-To: <1F3FD418-38D2-4A10-A882-666D4327F993@gmail.com>

```
On Tue, May 26, 2020 at 02:18:34PM +0800, Xirui Zhao wrote:

> Tested on git version 2.27.0-rc1 (latest build from master branch on github) and 2.26.2
> `git restore --staged file` on a newly created repository outputs
> error "fatal: could not resolve HEAD", but `git reset file` correctly
> unstages the file.

Yeah, "restore" is based on git-checkout, which is a little pickier than
"git reset" here. I don't think this ever worked in any version of
git-restore. It would probably be OK for it to use the empty tree when
HEAD is unborn, at least when operating in git-restore mode.

-Peff

```
