git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Checkout to different directory at certain commit without changing index
@ 2024-05-13  7:26 Ondra Medek
  2024-05-13 15:28 ` Phillip Wood
  0 siblings, 1 reply; 7+ messages in thread
From: Ondra Medek @ 2024-05-13  7:26 UTC (permalink / raw)
  To: git

Hello,
I need a simple script for unskilled users to do a fast checkout (LFS
friendly) of the current local Git clone at a certain commit to a
different directory I.e. something like "copy at a point in history".
IMO all possible solutions are summarized in this thread
https://stackoverflow.com/questions/160608/do-a-git-export-like-svn-export
I describe some of them with my remarks:

- git checkout-index : works with HEAD only.
- git archive: influenced by export-ignore and export-subst
attributes, so may not produce exact copy of sources. (And needs tar).
- git worktree add -d : needs cleanup: git prune or git remove.
- git clone: Unfortunately, -b param cannot work with commit hash and
does not respect local worktree settings (e.g. autocrlf). So, a
solution may be a bit complicated: git clone -s -n . dest/path ; cp
.git/config dest/path/.git ; cd dest/path ; git co -q <commit-ish> ;
rm -rf .git
- git checkout: Unfortunately, modifies Git index, so some action to
revert index is necessary after: git --work-tree=/path/to/checkout/
checkout -f -q <tree-ish> -- ./

For me, the best solution is with git clone, because it does not
modify Git index nor any source working tree settings, so no cleanup
is necessary. But it's a bit complicated, though. It seems to me that
"git checkout" could do this better and simpler if it would have some
param to not modify the Git index. Is it possible to enhance git
checkout? Or is there any other simple solution not mentioned in the
SO thread?

Thank you
Ondra Medek

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

end of thread, other threads:[~2024-05-15  5:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-13  7:26 Checkout to different directory at certain commit without changing index Ondra Medek
2024-05-13 15:28 ` Phillip Wood
2024-05-13 17:23   ` Ondra Medek
2024-05-14  6:29     ` Ondra Medek
2024-05-14 10:07       ` phillip.wood123
2024-05-15  5:07         ` Ondra Medek
2024-05-14 10:01     ` phillip.wood123

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