git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Extracting a file
@ 2021-07-22  8:48 Angelo Borsotti
  2021-07-22  9:05 ` Ævar Arnfjörð Bjarmason
  0 siblings, 1 reply; 8+ messages in thread
From: Angelo Borsotti @ 2021-07-22  8:48 UTC (permalink / raw)
  To: git

Hi,

sometimes there is a need to extract a file from a commit.
E.g. some changes have been applied to it in the work directory,
and the app being implemented no longer works properly.
It would be fine to have a look at that file, some commits ago,
when all worked fine.
Of course, it is possible to recover the entire old commit, or to
make a new branch, or checkout the file (which requires to save
the new one before), but the most simple and safe way is to
extract the file, giving it a new name.
That is possible, using this (hard to remember) trick:

git show HASH:file/path/name.ext > some_new_name.ext

Would not be better to have a "copy" command to copy a file from a commit
to a new one in the current directory?
This would make a git repository resemble a (readonly) filesystem, which
actually it is.
Note also that the ability to get from a repository what one has stored
in it is the most basic feature anyone wants from a repository.

Thank you
-Angelo Borsotti

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

end of thread, other threads:[~2021-07-23 18:17 UTC | newest]

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

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