From: Felipe Contreras <felipe.contreras@gmail.com>
To: Junio C Hamano <gitster@pobox.com>, Jeff King <peff@peff.net>
Cc: "Angelo Borsotti" <angelo.borsotti@gmail.com>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
git <git@vger.kernel.org>
Subject: Re: Extracting a file
Date: Fri, 23 Jul 2021 13:17:02 -0500 [thread overview]
Message-ID: <60fb079e38977_defb2087d@natae.notmuch> (raw)
In-Reply-To: <xmqq5yx1oty6.fsf@gitster.g>
Junio C Hamano wrote:
> Jeff King <peff@peff.net> writes:
>
> > On Thu, Jul 22, 2021 at 11:46:01AM +0200, Angelo Borsotti wrote:
> >
> >> Actually, I did not want to make git behave like a read-only filesystem,
> >> but only to be able to get what is stored in it using some easy to remember
> >> command.
> >>
> >> I guess that:
> >>
> >> git mv A B &&
> >> git checkout HEAD -- A
> >>
> >> renames file A in the work, current, directory to B, and then recovers
> >> A from the
> >> repository. This changes the file on which I am working. After having
> >> read the old
> >> A, and understood what changes I make that are not correct, I should delete A,
> >> and rename B back to A.
> >> If something gets wrong with this, I risk to damage my original A.
> >> This is why it is
> >> better not to change it, and instead get a copy of the old one with
> >> another name,
> >> which is what
> >>
> >> git show HASH:file/path/name.ext > some_new_name.ext
> >
> > You might also like "git checkout -p HASH -- A", which will let you pick
> > individual hunks from HASH:A and apply them to your working tree.
>
> There is
>
> git cat-file --textconv --filters HASH:A >my-temporary-file-to-inspect
>
> which would not touch the index or any tracked working tree file,
> other than the target of redirection.
Hmm, --textconv and --filters are incompatible with each other, did you
mean "--textconv | --filters"?
Also, this is simpler:
git cat-file -p HASH:A
Although I don't know how that's better than Angelo's `git show`.
FTR I do often use `git show commit:file` myself. I'm not sure if
we could do something particularly better than that.
--
Felipe Contreras
prev parent reply other threads:[~2021-07-23 18:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-22 8:48 Extracting a file Angelo Borsotti
2021-07-22 9:05 ` Ævar Arnfjörð Bjarmason
2021-07-22 9:46 ` Angelo Borsotti
2021-07-23 7:01 ` Jeff King
2021-07-23 7:38 ` Angelo Borsotti
2021-07-23 16:47 ` Junio C Hamano
2021-07-23 16:50 ` Junio C Hamano
2021-07-23 18:17 ` Felipe Contreras [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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=60fb079e38977_defb2087d@natae.notmuch \
--to=felipe.contreras@gmail.com \
--cc=angelo.borsotti@gmail.com \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
/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).