git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Altmanninger <aclopte@gmail.com>
To: Robin Moussu <moussu.robin@pm.me>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: Request: `git restore $commit $file` shouldn’t override uncommited changes
Date: Tue, 27 Apr 2021 21:29:06 +0200	[thread overview]
Message-ID: <20210427192906.7obdkopxwajqnv53@gmail.com> (raw)
In-Reply-To: <pYZzGPZTHnJjYBKrUAVGcso74I_xJgfzNpSwDN94fhYcDoOamp62-IFvxVrU056uw0txy3MTHYSwny_II0XY4trSY5_E25q7EXwhNHjy3VY=@pm.me>

> I would have expected that `git restore $commit $file` would copy the
> content of said file from another revision only if your don’t have
> uncommitted changes or to get an error.

The positional arguments to "git restore" are files.  So that command will
error unless a file called $commit exists.
(You shell's tab completion should guide you here.)
You can use the --source option to specify the commit.

> If it was really what I wanted to do, I would have expected to either do
> `git restore $file && git restore $commit $file`, directly `git restore
> --force $commit $file` or something similar.

Is your question that you expect a command like

	git restore --source=some-commit some-file

to error if you have uncommitted changes (to "some-file")?
And instead you would run

	git restore some-file
	git restore --source=some-commit some-file

  reply	other threads:[~2021-04-27 19:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-27 17:37 Request: `git restore $commit $file` shouldn’t override uncommited changes Robin Moussu
2021-04-27 19:29 ` Johannes Altmanninger [this message]
2021-04-28  8:35   ` Robin Moussu
2021-04-28  9:10     ` Junio C Hamano
2021-04-28  7:23 ` Junio C Hamano

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210427192906.7obdkopxwajqnv53@gmail.com \
    --to=aclopte@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=moussu.robin@pm.me \
    /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.
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 NNTP newsgroup(s).