Subject: Re: moving a repository question

From: Junio C Hamano <[email-masked]>
Date: Thu, 14 Jul 2022 15:59:55 -0700

Paul Kinzelman <[email-masked]> writes:

> I barely qualify as a novice on git, so my apologies in advance if this is a
> stupid question.
>
> Is everything that git needs stored in the .git tree?

Depends on what you want to do with "Git".

If you only copy .git/ and no file from the working tree, your "git
status" in the new location will report "you removed all the files
and you have nothing", for example.  If you are willing to do "git
reset --hard" after making such a copy of ".git/", it may be OK.  If
you had local changes in the working tree before taking a copy of
.git/, doing "git reset --hard" in the new location may not recover
the local changes in the original, so it may not be good and you may
have to copy the working tree files as well.

If you are using multiple worktrees linked to the repository,
copying .git/ is an absolute no-no.  Locations of secondary
worktrees are recorded in .git/ somewhere and copying them literally
would mean the new copy would mistakenly think that these secondary
worktrees linked to the original repository are linked to the new
copy instead.  There may be other things that will cause confusions
when copied.

"git clone" will of course sidestep all of these problems.